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

ensure file is not in cache before calling require #3085

Closed

Conversation

finnigantime
Copy link
Contributor

@finnigantime finnigantime commented Oct 25, 2017

Description of the Change

Fixes #3084.

Alternate Designs

Could have modified require.cache directly, but seems easier to add the decache dependency and it handle modifying the require.cache for us.

Why should this be in core?

Mocha makes an assumption that when loading files, require(file) will parse a file and encounter mocha directives. For this to be valid, mocha should ensure the file is not in the require cache.

Benefits

Allows mocha to be used programmatically in scripts/environments where modules mocha is going to run tests on have already been loaded (perhaps by a previous invocation of mocha itself).

Possible Drawbacks

None that come to mind immediately, other than risk by having the decache dependency, though I think having that dependency makes sense here.

Applicable issues

bug fix

@jsf-clabot
Copy link

jsf-clabot commented Oct 25, 2017

CLA assistant check
All committers have signed the CLA.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.05%) to 89.86% when pulling 8618e7f on finnigantime:finnigantime/decache into da901da on mochajs:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.05%) to 89.86% when pulling 7c3e89d on finnigantime:finnigantime/decache into da901da on mochajs:master.

@boneskull
Copy link
Contributor

thanks. as @ScottFreeCode wrote in #3084, we can't just blast the cache wholesale. if we're going to have this capability baked in to core, the solution is going to be much more nuanced.

@boneskull boneskull closed this Dec 7, 2017
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.

mocha no-ops when calling require() on file that is in node cache
4 participants