Skip to content

Commit dc736d6

Browse files
committed
add spy.mockReset behaviour change to Jest migration guide
1 parent 70fbaaa commit dc736d6

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

docs/guide/migration.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,14 @@ Jest has their [globals API](https://jestjs.io/docs/api) enabled by default. Vit
297297

298298
If you decide to keep globals disabled, be aware that common libraries like [`testing-library`](https://testing-library.com/) will not run auto DOM [cleanup](https://testing-library.com/docs/svelte-testing-library/api/#cleanup).
299299

300+
### `spy.mockReset`
301+
302+
Jest's [`mockReset`](https://jestjs.io/docs/mock-function-api#mockfnmockreset) replaces the mock implementation with an
303+
empty function that returns `undefined`.
304+
305+
Vitest's [`mockReset`](/api/mock#mockreset) resets the mock implementation to its original.
306+
That is, resetting a mock created by `vi.fn(impl)` will reset the mock implementation to `impl`.
307+
300308
### Module Mocks
301309

302310
When mocking a module in Jest, the factory argument's return value is the default export. In Vitest, the factory argument has to return an object with each export explicitly defined. For example, the following `jest.mock` would have to be updated as follows:

0 commit comments

Comments
 (0)