-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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 ability to unload files from require
cache
#3534
Conversation
Added new public `unloadFiles` method to undo `loadFiles` for programmatic use. Implemented via private `unloadFile` method.
Replaced markdown in comment with corresponding HTML.
Previous discussion can be found in original PR #3388. |
require
cacherequire
cache
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should document this on the site.
Other than that, just some suggestions/comments; no other major issues.
What is this in reference to? More than the API docs? |
Converted from 'to have property' to 'to have keys', eliminating `forEach` loops. Saved results of `require.resolve` to variable to prevent rework.
@boneskull anything else? |
@plroebuck I mean in |
the other changes look good |
this still needs documentation if we want it in v6.0.0 |
hmm, no, I guess it doesn't need documenting on the main site. |
Description of the Change
Adds a feature which allows unloading test files from
require
cache programmatically.This feature simplifies rerunning tests since there is no need to recreate the Mocha instance.
Currently handled by one of these options:
Alternative Designs
A potentially more complete design could take a snapshot of the cache before testing begins and remove everything added afterwards. Prefer to see how well this implementation does before going further.
Why should this be in core?
Benefits
Better reusability, fewer headaches for programmers.
Possible Drawbacks
Still possible that even though registered files were unloaded from the
require
cache,they may have in turn
require
d something else which will remain in the cache.Applicable issues
semver-minor