Answer the question
In order to leave comments, you need to log in
How to rewrite mocks from jest.mock method to jest.spyOn?
Let's say there is such a mock, but it is not suitable for all tests, so they asked me to remake it on spyOn - after each test, reset it, having smoked the documentation and did not understand who fumbles in jest, tell me?
jest.mock('/../data/api', () => {
const apiData: {makeApiData} = require('@bcs/sdk/lib/sdk-core/monads/api-data');
return ({
StatusName: {
Confirmed: 'Подтвержден',
InWork: 'В работе',
},
ProcessingWay: {
Outbound: 'Outbound',
},
dentityCheck: {
Courier: 'Курьер',
},
Api: jest.fn(() => ({
getId: () => () => apiData.makeApiData(success(data)),
getIds: () => () => apiData.makeApiData(success(data2))
}),
});
};
it('test', async () => {
const dispatched = await recordSaga(dataSaga, { payload: '10101', type: dataConst });
expect(dispatched).toBe(true);
});
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question