Skip to content

Commit

Permalink
Update README.md (#127)
Browse files Browse the repository at this point in the history
Change resetAllMocks to clearAllMocks
Add clarity
  • Loading branch information
AOEChamp authored Mar 5, 2021
1 parent c6217cc commit 46212d2
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,14 +166,15 @@ Reset your `localStorage` data and mocks before each test to prevent leaking.

```js
beforeEach(() => {
// values stored in tests will also be available in other tests unless you run
// to fully reset the state between tests, clear the storage
localStorage.clear();
// or directly reset the storage
localStorage.__STORE__ = {};
// you could also reset all mocks, but this could impact your other mocks
jest.resetAllMocks();
// or individually reset a mock used
// and reset all mocks
jest.clearAllMocks();

// clearAllMocks will impact your other mocks too, so you can optionally reset individual mocks instead:
localStorage.setItem.mockClear();
// you can also directly reset the storage (same as .clear above)
localStorage.__STORE__ = {};
});

test('should not impact the next test', () => {
Expand Down

0 comments on commit 46212d2

Please sign in to comment.