Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update README.md bug #127

Merged
merged 1 commit into from
Mar 5, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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