jest-react-hooks-shallow icon indicating copy to clipboard operation
jest-react-hooks-shallow copied to clipboard

Not working correctly with beforeAll

Open ebuzzz opened this issue 3 years ago • 0 comments

We're currently using this project with both shallow and mount renders. In some tests we use beforeAll with the render function:

  const renderComponent = () => {
    component = mount(<LinkEditor {...props} />);
  };

  beforeEach(renderComponent);

The issue here is that beforeAll is always executed before beforeEach. And the mocks are setup in a beforeEach call. Changing the beforeEach in the library to beforeAll fixes this. But this seems not the best solution, as this might break things. Would it be possible to also add a beforeAll to mock the methods? Or let the user specify which before-method they want to trigger the mocks on?

ebuzzz avatar Aug 02 '21 15:08 ebuzzz