From c92ced37371be09e1d028e81cd0c86365e5607ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20M=C3=BCller?= Date: Tue, 6 Aug 2024 16:39:58 +0200 Subject: [PATCH 1/3] Change docs for mocha-json mochajs/mocha#4607 has been merged --- README.md | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/README.md b/README.md index e98cc2d..855867f 100644 --- a/README.md +++ b/README.md @@ -310,13 +310,9 @@ Configuration of `uniqueOutputName`, `suiteNameTemplate`, `classNameTemplate`, ` You can use the following example configuration in `package.json`: ```json "scripts": { - "test": "mocha --reporter json > test-results.json" + "test": "mocha --reporter json --reporter-option output=test-results.json" } ``` - -Test processing might fail if any of your tests write anything on standard output. -Mocha, unfortunately, doesn't have the option to store `json` output directly to the file, and we have to rely on redirecting its standard output. -There is a work in progress to fix it: [mocha#4607](https://github.com/mochajs/mocha/pull/4607)
From 3847ac0f9864b0aad88f840e7e129be3dcb1d314 Mon Sep 17 00:00:00 2001 From: Jozef Izso Date: Fri, 30 Aug 2024 11:28:19 +0200 Subject: [PATCH 2/3] Remove unused development dependency `@types/github-slugger` The `@types/github-slugger` was removed in commit 95d3d1fb853a25ce999d162cea060ccb372f8306 --- package-lock.json | 7 ------- package.json | 1 - 2 files changed, 8 deletions(-) diff --git a/package-lock.json b/package-lock.json index efc0684..08e4f92 100644 --- a/package-lock.json +++ b/package-lock.json @@ -23,7 +23,6 @@ "@octokit/webhooks": "^12.0.11", "@octokit/webhooks-types": "^7.3.1", "@types/adm-zip": "^0.5.5", - "@types/github-slugger": "^1.3.0", "@types/jest": "^29.5.12", "@types/node": "^18.19.32", "@types/picomatch": "^2.3.3", @@ -1614,12 +1613,6 @@ "@types/responselike": "^1.0.0" } }, - "node_modules/@types/github-slugger": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/@types/github-slugger/-/github-slugger-1.3.0.tgz", - "integrity": "sha512-J/rMZa7RqiH/rT29TEVZO4nBoDP9XJOjnbbIofg7GQKs4JIduEO3WLpte+6WeUz/TcrXKlY+bM7FYrp8yFB+3g==", - "dev": true - }, "node_modules/@types/graceful-fs": { "version": "4.1.9", "resolved": "https://registry.npmjs.org/@types/graceful-fs/-/graceful-fs-4.1.9.tgz", diff --git a/package.json b/package.json index af7822d..f7d45f0 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,6 @@ "@octokit/webhooks": "^12.0.11", "@octokit/webhooks-types": "^7.3.1", "@types/adm-zip": "^0.5.5", - "@types/github-slugger": "^1.3.0", "@types/jest": "^29.5.12", "@types/node": "^18.19.32", "@types/picomatch": "^2.3.3", From d61b558e8df85cb60d09ca3e5b09653b4477cea7 Mon Sep 17 00:00:00 2001 From: Monkey Do Date: Tue, 30 Nov 2021 14:02:54 +0100 Subject: [PATCH 3/3] Update mocha-json usage instructions Cherry pick commit ceb9822f8b07d0b13c526c659140f92c94f5b4af --- README.md | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 855867f..0d175a6 100644 --- a/README.md +++ b/README.md @@ -307,12 +307,22 @@ Configuration of `uniqueOutputName`, `suiteNameTemplate`, `classNameTemplate`, ` - Mocha version [v7.2.0](https://github.com/mochajs/mocha/releases/tag/v7.2.0) or higher - Usage of [json](https://mochajs.org/#json) reporter. -You can use the following example configuration in `package.json`: +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`: ```json "scripts": { "test": "mocha --reporter json --reporter-option output=test-results.json" } ``` + +For Mocha < v9.1, the command should look like this: +```json +"scripts": { + "test": "mocha --reporter json > test-results.json" +} +``` +Additionally, test processing might fail if any of your tests write anything on standard output. +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)). +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.