@reporters/mocha 1.3.0 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +9 -8
- package/package.json +2 -2
package/index.js
CHANGED
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
/* eslint-disable class-methods-use-this */
|
|
2
2
|
/* eslint-disable no-underscore-dangle */
|
|
3
|
-
/* eslint-disable max-classes-per-file */
|
|
4
3
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const Mocha = require('mocha');
|
|
9
|
-
const { loadOptions } = require('mocha/lib/cli');
|
|
4
|
+
import { EventEmitter } from 'node:events';
|
|
5
|
+
import Mocha from 'mocha';
|
|
6
|
+
import { loadOptions } from 'mocha/lib/cli/options.js';
|
|
10
7
|
|
|
11
8
|
const {
|
|
12
9
|
EVENT_RUN_BEGIN,
|
|
@@ -105,6 +102,7 @@ class Test {
|
|
|
105
102
|
this.started = true;
|
|
106
103
|
}
|
|
107
104
|
|
|
105
|
+
/* c8 ignore start */ // mocha-reporter API compatibility; not exercised internally
|
|
108
106
|
get isSuite() {
|
|
109
107
|
return this.kind === 'suite';
|
|
110
108
|
}
|
|
@@ -116,6 +114,7 @@ class Test {
|
|
|
116
114
|
get tests() {
|
|
117
115
|
return this.children.filter((child) => !child.isSuite);
|
|
118
116
|
}
|
|
117
|
+
/* c8 ignore stop */
|
|
119
118
|
}
|
|
120
119
|
|
|
121
120
|
class Runner extends EventEmitter {
|
|
@@ -298,6 +297,7 @@ class Runner extends EventEmitter {
|
|
|
298
297
|
}
|
|
299
298
|
|
|
300
299
|
#closeActiveSuites() {
|
|
300
|
+
/* c8 ignore start */ // only runs when a suite is still open at run end
|
|
301
301
|
for (let i = this.#activeNodes.length - 1; i >= 0; i -= 1) {
|
|
302
302
|
const node = this.#activeNodes[i];
|
|
303
303
|
if (node && node.isSuite) {
|
|
@@ -305,11 +305,12 @@ class Runner extends EventEmitter {
|
|
|
305
305
|
this.#activeNodes[i] = undefined;
|
|
306
306
|
}
|
|
307
307
|
}
|
|
308
|
+
/* c8 ignore stop */
|
|
308
309
|
this.#trimActiveNodes();
|
|
309
310
|
}
|
|
310
311
|
}
|
|
311
312
|
|
|
312
|
-
|
|
313
|
+
export default async function mochaReporter(source) {
|
|
313
314
|
const runner = new Runner();
|
|
314
315
|
await runner.init();
|
|
315
316
|
|
|
@@ -329,4 +330,4 @@ module.exports = async function mochaReporter(source) {
|
|
|
329
330
|
}
|
|
330
331
|
|
|
331
332
|
runner.end();
|
|
332
|
-
}
|
|
333
|
+
}
|