IssueRaiser

Proposal: Revert override of jest default `resetMocks`

## About Hey what's up! I found myself trying to work out why all my tests broke when upgrading react-scripts and then realized it's because of the change to enabling `resetMocks` by default. I wanted to challenge this decision because, especially when react-scripts is targeted at newer users looking to use react, this causes [fundamental jest examples online](https://jestjs.io/docs/en/jest-object#jestcreatemockfrommodulemodulename) to break. ## App-wide mocks It also means app-wide mocks such as these don't work. ```js // some-mocked-module.js export const useSomeHook = jest.fn(() => true); ``` ```js // setupTests.js jest.mock('some-mocked-module', () => ({ useSomeHook: jest.fn(() => true) })) ``` For new users, I can see why it would be very confusing.

Posted by andyrichardson on Oct 28, 2020, 3:36 PM

Tags

Related issues

Raise real-world problems, find people facing the same issue, and discuss solutions.3,000 issues0 comments

github (SaaS)

Proposal: Revert override of jest default `resetMocks`

andyrichardsonOct 28, 2020, 3:36 PM

## About Hey what's up! I found myself trying to work out why all my tests broke when upgrading react-scripts and then realized it's because of the change to enabling `resetMocks` by default. I wanted to challenge this decision because, especially when react-scripts is targeted at newer users looking to use react, this causes [fundamental jest examples online](https://jestjs.io/docs/en/jest-object#jestcreatemockfrommodulemodulename) to break. ## App-wide mocks It also means app-wide mocks such as these don't work. ```js // some-mocked-module.js export const useSomeHook = jest.fn(() => true); ``` ```js // setupTests.js jest.mock('some-mocked-module', () => ({ useSomeHook: jest.fn(() => true) })) ``` For new users, I can see why it would be very confusing.

Comments (0)

No comments yet. Start the discussion.

Comment on this issue