I’m currently using mockGraphQLMutation
in a unit test I’m writing for one of my pages. The below isn’t exact code, but similar enough:
it('some test', () => {
mockGraphQLMutation('UpdateUserMutation', () => {
return {
id: 1,
name: 'Bob',
}
})
})
Now in the page with the mutation, I’m using the useMutation
hook:
const [UpdateUserMutation] = useMutation(
MUTATION_NAME,
{
onCompleted: () => {
navigate(routes.messages())
},
}
)
I’m testing in my unit test that the onCompleted function is being called – specifically I’ve mocked the navigate
function and am asserting it’s called at least once, but I’m not seeing that behavior. Is there anything I might be doing wrong here?