renovate icon indicating copy to clipboard operation
renovate copied to clipboard

refactor(jest): enable `resetMocks`

Open JamieMagee opened this issue 3 years ago • 1 comments

Changes

  • Sets resetMocks^1 in jest.config.ts (equivalent to calling jest.resetAllMocks^2 before each test)
  • Removes any explicit calls to jest.resetAllMocks
  • Fixes tests that were relying on mocks from other tests

This automatically clears mock implementations or return values before every test. This makes it more difficult to write tests which rely on each other.

Tests still to fix:

  • [ ] ...

Context

Second part of #18768 Follow-up from #18779

Documentation (please check one with an [x])

  • [ ] I have updated the documentation, or
  • [x] No documentation update is required

How I've tested my work (please tick one)

I have verified these changes via:

  • [ ] Code inspection only, or
  • [x] Newly added/modified unit tests, or
  • [ ] No unit tests but ran on a real repository, or
  • [ ] Both unit tests + ran on a real repository

JamieMagee avatar Nov 16 '22 06:11 JamieMagee

What's the path forward for this?

rarkins avatar Dec 17 '22 08:12 rarkins

@JamieMagee might be good to pull in the latest changes from main, because @zharinov changed a lot of test-related stuff.

HonkingGoose avatar Jun 16 '23 12:06 HonkingGoose