From 1fe25ef40369a566f5550a62d3e00bbcff2ceacb Mon Sep 17 00:00:00 2001 From: Pat Finnigan Date: Thu, 23 Nov 2017 19:27:00 -0800 Subject: [PATCH] add comment about the require cache, per guidance in https://github.com/mochajs/mocha/issues/3084#issuecomment-342394332 --- Using-mocha-programmatically.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Using-mocha-programmatically.md b/Using-mocha-programmatically.md index 6169d80355..3072a18cf6 100644 --- a/Using-mocha-programmatically.md +++ b/Using-mocha-programmatically.md @@ -31,7 +31,7 @@ mocha.run(function(failures){ }); ``` -`mocha.run()` returns a `Runner` instance which emits many [events](https://github.com/mochajs/mocha/blob/8cae7a34f0b6eafeb16567beb8852b827cc5956b/lib/runner.js#L47-L57) of interest. +`mocha.run()` returns a `Runner` instance which emits many [events](https://github.com/mochajs/mocha/blob/8cae7a34f0b6eafeb16567beb8852b827cc5956b/lib/runner.js#L47-L57) of interest. Note that `run` (via `loadFiles`, which it calls) relies on Node's `require` to execute the test interface functions. Thus, files loaded by mocha will be stored in Node's `require` cache and therefore tests in these files will not be re-run if `mocha.run()` is called again. If you want to run tests multiple times, you may need to clear Node's `require` cache before subsequent calls in whichever manner best suits your needs. ## Set options