Skip to content

Commit d61b558

Browse files
MonkeyDojozefizso
authored andcommitted
Update mocha-json usage instructions
Cherry pick commit ceb9822
1 parent fd38649 commit d61b558

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

README.md

+11-1
Original file line numberDiff line numberDiff line change
@@ -307,12 +307,22 @@ Configuration of `uniqueOutputName`, `suiteNameTemplate`, `classNameTemplate`, `
307307
- Mocha version [v7.2.0](https://github.com/mochajs/mocha/releases/tag/v7.2.0) or higher
308308
- Usage of [json](https://mochajs.org/#json) reporter.
309309

310-
You can use the following example configuration in `package.json`:
310+
For Mocha >= [v9.1.0](https://github.com/mochajs/mocha/releases/tag/v9.1.0), you can use the following example configuration in `package.json`:
311311
```json
312312
"scripts": {
313313
"test": "mocha --reporter json --reporter-option output=test-results.json"
314314
}
315315
```
316+
317+
For Mocha < v9.1, the command should look like this:
318+
```json
319+
"scripts": {
320+
"test": "mocha --reporter json > test-results.json"
321+
}
322+
```
323+
Additionally, test processing might fail if any of your tests write anything on standard output.
324+
Before version [v9.1.0](https://github.com/mochajs/mocha/releases/tag/v9.1.0), Mocha doesn't have the option to store `json` output directly to the file, and we have to rely on redirecting its standard output ([mocha#4607](https://github.com/mochajs/mocha/pull/4607)).
325+
Please update Mocha to version [v9.1.0](https://github.com/mochajs/mocha/releases/tag/v9.1.0) or above if you encounter this issue.
316326
</details>
317327

318328
<details>

0 commit comments

Comments
 (0)