-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
Add the ability to specify modules to reset in jest.resetModules #6638
Comments
jest.resetModules()
How about filling issue template? |
Hi, thanks for reporting! This seems like an interesting use case. Here is the code for My initial impression is that if we want to support this, it would not be that hard, except for a couple of things:
Given that |
@benmj I understand the use case for just resetting one module rather than all of them. I'm trying to reproduce and better understand the implications of:
Do you mind providing an example? Is this similar to what you are mentioning? import x from './withLocalState';
import y from './stateless';
beforeEach(() => {
jest.resetModules();
});
it('some test', () => {
// In here `y` is still the correct object right?
}) |
@benmj our Feature Proposal template should be followed for all feature proposals. It has sections for questions that will come up like the ones @rogeliog brings up I think this is a great proposal, so let us know when you update the description to follow that template and we'll reopen |
Would #6174 fulfill the use case? |
Thanks for the comments. I've updated to follow the template. |
Thanks for the update 👍 |
Closing in favor of #6174 |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
🚀 Feature Proposal
Allow passing variable arguments to
jest.resetModules
to specify which modules should be reset.Motivation
I have several files that contain local state which I would like to reset between tests. However, I do not want to reset and re-import all of the dependencies in the test file because this seems 1) unnecessary and 2) error prone and easy to forget.
Example
Current
Here is a somewhat simplified example:
Desired
Pitch
It would remove cruft, add specificity, and give finer-grained control.
The text was updated successfully, but these errors were encountered: