Hey, community! I updated packages(apollo/client, react-scripts, typescript, etc) to the latest versions in my project and got errors in mutations and it happens only in the testing. On the browser all ok and works as should.
Error:
Cannot read property 'errors' of undefined
at new ApolloError (node_modules/@apollo/client/errors/index.js:31:28)
at Object.error (node_modules/@apollo/client/core/QueryManager.js:135:83)
at notifySubscription (node_modules/zen-observable/lib/Observable.js:140:18)
at onNotify (node_modules/zen-observable/lib/Observable.js:179:3)
at SubscriptionObserver.error (node_modules/zen-observable/lib/Observable.js:240:7)
at node_modules/@apollo/client/utilities/observables/asyncMap.js:27:40
Mutation mock:
const mock: MockedResponse = {
request: {
query: MyMutation,
variables: {
something: 22,
},
},
result: jest.fn(() => ({
data: {
somethingData: {
something: 22,
},
},
})),
};
...
<MockedProvider
mocks={[mock]}
addTypename={false}
defaultOptions={{ watchQuery: { fetchPolicy: 'no-cache' } }}
>
<Component />
</MockedProvider>
Maybe anyone has ideas what can be wrong🤷🏻♂️