Open Spoutnik97 opened 2 years ago
I have this question too
I also have this question and I get Mocked response should contain either result or error
when trying to use newData
. even though newData
exists on the type
The same happens for query - both result and newData can be checked if they're called but we cannot make assertion about variables.
@RichMatthews - you cannot use newData alone, you have to either pass result or error. newData
is used for requests after initial one
I think the validation of what is being sent as a mutation variable is already done when you mock your request right?
If your mocked variable object is different from what the test is sending, then the test would fail. You do not need an explicit toHaveBeenCalledWith
instead just toHaveBeenCalled
is enough.
@Spoutnik97
If you want your test to work fine, kindly update this to pass correct emailId await fireEvent.changeText(emailInput, 'test@test.com');
because your mock is expecting email: 'test@bam.tech'
and then assert
expect(mocks[0].newData).toHaveBeenCalled();
Hi,
I would like to test what variables are sent with my mutation. I have a reset password screen in React Native.
I saw [this article] (https://jkettmann.com/testing-apollo-how-to-test-if-a-mutation-was-called-with-mockedprovider) talking about
newData
key in mocks, but unfortunatelly, this function called withundefined
...Could you help me to understand what happens please?
My test:
The test result displays: