Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/src/content/docs/explainers/programmatic-usage.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ mocha.run(function (failures) {
});
```

`mocha.run()` returns a `Runner` instance which emits many [events](https://github.com/mochajs/mocha/blob/9a7053349589344236b20301de965030eaabfea9/lib/runner.js#L52) of interest.
`mocha.run()` returns a `Runner` instance which emits many [events](https://github.com/mochajs/mocha/blob/main/lib/runner.js) of interest, exposed as `Mocha.Runner.constants` (e.g. `EVENT_TEST_PASS`, `EVENT_TEST_FAIL`, `EVENT_RUN_END`).
Comment thread
mark-wiemer marked this conversation as resolved.
Resolved

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. The upcoming Mocha-6.0 release will provide `Mocha#unloadFiles`, which will remove all files loaded by `Mocha#loadFiles`.
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. `Mocha#unloadFiles` is also available and will remove all files loaded by `Mocha#loadFiles`.

Unfortunately, event listeners in multiple places are not yet configured for restartability; for now, we recommend recreating the `mocha` instance before rerunning to _ensure_ everything gets reset properly.

Expand Down
8 changes: 4 additions & 4 deletions docs/src/content/docs/explainers/typescript.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ Or in `.mocharc.js`:

```js
export default {
"node-option": ["strip-types"]
"extension": ["js", "ts"]
"spec": ["test/**/*.ts"]
}
"node-option": ["experimental-strip-types"],
extension: ["js", "ts"],
spec: ["test/**/*.ts"],
};
```

:::note
Expand Down
2 changes: 1 addition & 1 deletion docs/src/content/docs/features/global-fixtures.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ At first glance, _global fixtures_ seem similar to [root hook plugins](/features
However, unlike root hooks, global fixtures:

1. Are _guaranteed_ to execute _once and only once_
1. Work identically parallel mode, watch mode, and serial mode
1. Work identically in parallel mode, watch mode, and serial mode
1. Do not share a context with tests, suites, or other hooks

There are two types of global fixtures: [global setup fixtures](#global-setup-fixtures) and [global teardown fixtures](#global-teardown-fixtures).
Expand Down
2 changes: 1 addition & 1 deletion docs/src/content/docs/features/root-hook-plugins.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ describe("my test suite", function () {

Running `mocha --require test/hooks.js test/test.spec.js` will run as before (and is now ready to be used with [`--parallel`](/running/cli#--parallel--p)).

## Migrating a Library to use Root Hook PLugins
## Migrating a Library to use Root Hook Plugins

If you're a library maintainer, and your library uses root hooks, you can migrate by refactoring your entry point:

Expand Down
Loading