How do I rewrite mocks from jest.mock to jest.spyOn?

  • 0
    Let's say there is such a mock, but it is not suitable for all tests, so they asked to change it to spyOn - after each test, reset it, having smoked the documentation and did not understand who was fumbling 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))
        }),
      });
    };

    well, the test itself, but it is not important, someone will ask you to show someone you love)
    it('test', async () => {
        const dispatched = await recordSaga(dataSaga, { payload: '10101', type: dataConst });
        expect(dispatched).toBe(true);
      });
    JavaScript Sadie Ritter, Aug 29, 2019

  • 0 Answers
Your Answer
To place the code, please use CodePen or similar tool. Thanks you!