mercredi 7 octobre 2020

Difference between jest.mock and jest.doMock

I want this to be specific to a single test:

  it('should mock the module a single time', () => {
    jest.doMock('../../../../../../../components/HighCharts/HighCharts', () => {
      return () => <div id="mock-line-chart" />;
    });
  })

but it doesnt work. This works for the whole file:

jest.mock('../../../../../../../components/HighCharts/HighCharts', () => {
  return () => <div id="my-special-div" />;
});

Am I not using this right? Where is the difference between doMock and mock. I it suitable to do a module mock for a single test only?

Aucun commentaire:

Enregistrer un commentaire