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

Make setup function callable to reset mocks between tests #107

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

trevoreyre
Copy link

@trevoreyre trevoreyre commented Jul 1, 2019

This addresses #83

It makes the export of src/setup.js a callable function, so if you need to reset all of your Jest mocks between test runs, you can call the setup function again to reset your localStorage mock.

import { setup } from 'jest-localstorage-mock/dist/setup'

beforeEach(() => {
  setup()
})

afterEach(() => {
  jest.resetAllMocks()
}

The default export of the library will work the same as before. I'm not sure if this is exactly how you would like to resolve this issue, so I'm open to feedback. And I think the README.md would probably need to be updated to mention this option.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant