In Cypress e2e test, I was using cy.intercept
to intercept a graphql call and make it return mocked response.
Now I am trying to do the same in my Vue component test (mount the component, take some action to make a call to occur) but it seems doing nothing, a call ends up getting null response.
Wonder if I need some setup to make this working? (I'm using Cypress@10.7.0)
const queryName = 'myQuery'
const aliasName = aliasGraphqlName('Query', queryName)
const responseMyQuery = { "data": { ... } }
// beforeEach
cy.intercept('POST', graphqlUrl, (req) => {
aliasGraphqlQuery(req, queryName)
if (req.alias && req.alias === aliasName) {
req.reply(responseMyQuery)
}
})
// my test
cy.mount(MyComponent, {...})
cy.get('[data-test=myField] button.mdi-pencil')
.click() // api call gets null not responseMyQuery