mocha-qase-reporter 1.1.5 → 1.1.7
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/changelog.md +6 -0
- package/dist/extraReporters.d.ts +1 -1
- package/dist/extraReporters.js +36 -15
- package/dist/reporter.js +3 -5
- package/docs/usage.md +15 -34
- package/package.json +9 -9
- package/tsconfig.build.json +3 -1
package/changelog.md
CHANGED
package/dist/extraReporters.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ export type ExtraReportersConfig = string | ExtraReporterConfig | (string | Extr
|
|
|
8
8
|
* Parses extraReporters configuration from Mocha options
|
|
9
9
|
* Supports both string format and object format
|
|
10
10
|
*/
|
|
11
|
-
export declare function parseExtraReporters(options: Mocha.MochaOptions): ExtraReportersConfig | undefined;
|
|
11
|
+
export declare function parseExtraReporters(options: Mocha.MochaOptions, config?: Record<string, unknown>): ExtraReportersConfig | undefined;
|
|
12
12
|
/**
|
|
13
13
|
* Creates and configures additional reporters based on extraReporters config
|
|
14
14
|
*/
|
package/dist/extraReporters.js
CHANGED
|
@@ -8,20 +8,32 @@ exports.validateExtraReportersForParallel = validateExtraReportersForParallel;
|
|
|
8
8
|
* Parses extraReporters configuration from Mocha options
|
|
9
9
|
* Supports both string format and object format
|
|
10
10
|
*/
|
|
11
|
-
function parseExtraReporters(options) {
|
|
11
|
+
function parseExtraReporters(options, config) {
|
|
12
|
+
// First, try to get extraReporters from Mocha reporterOptions
|
|
12
13
|
const reporterOptions = options.reporterOptions;
|
|
13
|
-
if (
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
14
|
+
if (reporterOptions) {
|
|
15
|
+
// Handle different formats of extraReporters from Mocha options
|
|
16
|
+
if (typeof reporterOptions['extraReporters'] === 'string') {
|
|
17
|
+
return reporterOptions['extraReporters'];
|
|
18
|
+
}
|
|
19
|
+
if (Array.isArray(reporterOptions['extraReporters'])) {
|
|
20
|
+
return reporterOptions['extraReporters'];
|
|
21
|
+
}
|
|
22
|
+
if (typeof reporterOptions['extraReporters'] === 'object' && reporterOptions['extraReporters'] !== null) {
|
|
23
|
+
return reporterOptions['extraReporters'];
|
|
24
|
+
}
|
|
22
25
|
}
|
|
23
|
-
|
|
24
|
-
|
|
26
|
+
// If not found in Mocha options, try to get from qase.config.json
|
|
27
|
+
if (config && config['extraReporters']) {
|
|
28
|
+
if (typeof config['extraReporters'] === 'string') {
|
|
29
|
+
return config['extraReporters'];
|
|
30
|
+
}
|
|
31
|
+
if (Array.isArray(config['extraReporters'])) {
|
|
32
|
+
return config['extraReporters'];
|
|
33
|
+
}
|
|
34
|
+
if (typeof config['extraReporters'] === 'object' && config['extraReporters'] !== null) {
|
|
35
|
+
return config['extraReporters'];
|
|
36
|
+
}
|
|
25
37
|
}
|
|
26
38
|
return undefined;
|
|
27
39
|
}
|
|
@@ -68,9 +80,18 @@ function createExtraReporters(runner, options, extraReportersConfig) {
|
|
|
68
80
|
}
|
|
69
81
|
}
|
|
70
82
|
if (ReporterClass && typeof ReporterClass === 'function') {
|
|
71
|
-
// Create reporter instance with options
|
|
72
|
-
const
|
|
73
|
-
|
|
83
|
+
// Create reporter instance with clean options (without main reporter options)
|
|
84
|
+
const cleanOptions = {
|
|
85
|
+
...options,
|
|
86
|
+
// Remove main reporter property
|
|
87
|
+
reporter: undefined,
|
|
88
|
+
// Add extra reporter specific options to all reporter option properties
|
|
89
|
+
// This ensures compatibility with different reporters that may expect different property names
|
|
90
|
+
reporterOptions,
|
|
91
|
+
reporterOption: reporterOptions,
|
|
92
|
+
'reporter-option': reporterOptions
|
|
93
|
+
};
|
|
94
|
+
const reporter = new ReporterClass(runner, cleanOptions);
|
|
74
95
|
reporters.push(reporter);
|
|
75
96
|
}
|
|
76
97
|
}
|
package/dist/reporter.js
CHANGED
|
@@ -50,7 +50,7 @@ class MochaQaseReporter extends mocha_1.reporters.Base {
|
|
|
50
50
|
super(runner, options);
|
|
51
51
|
const config = configLoader.load();
|
|
52
52
|
// Parse and validate extraReporters configuration
|
|
53
|
-
const extraReportersConfig = (0, extraReporters_1.parseExtraReporters)(options);
|
|
53
|
+
const extraReportersConfig = (0, extraReporters_1.parseExtraReporters)(options, config || undefined);
|
|
54
54
|
this.reporter = qase_javascript_commons_1.QaseReporter.getInstance({
|
|
55
55
|
...(0, qase_javascript_commons_1.composeOptions)(options, config),
|
|
56
56
|
frameworkPackage: 'mocha',
|
|
@@ -129,11 +129,9 @@ class MochaQaseReporter extends mocha_1.reporters.Base {
|
|
|
129
129
|
output.stderr += data;
|
|
130
130
|
this.testOutputs.set(test.title, output);
|
|
131
131
|
});
|
|
132
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
133
|
-
// @ts-expect-error
|
|
132
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment,@typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-call
|
|
134
133
|
process.stdout.write = stdoutInterceptor.write.bind(stdoutInterceptor);
|
|
135
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
136
|
-
// @ts-expect-error
|
|
134
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment,@typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-call
|
|
137
135
|
process.stderr.write = stderrInterceptor.write.bind(stderrInterceptor);
|
|
138
136
|
this.testOutputs.set(test.title, { stdout: '', stderr: '' });
|
|
139
137
|
this.addMethodsToContext(test.ctx);
|
package/docs/usage.md
CHANGED
|
@@ -277,7 +277,7 @@ The Qase reporter supports additional reporters alongside the main Qase reporter
|
|
|
277
277
|
|
|
278
278
|
### Configuration
|
|
279
279
|
|
|
280
|
-
You can configure extra reporters using the `extraReporters` option in the
|
|
280
|
+
You can configure extra reporters using the `extraReporters` option in the `qase.config.json` file or via command line:
|
|
281
281
|
|
|
282
282
|
#### Command Line
|
|
283
283
|
|
|
@@ -292,43 +292,24 @@ QASE_MODE=testops mocha --reporter mocha-qase-reporter --reporter-options extraR
|
|
|
292
292
|
QASE_MODE=testops mocha --reporter mocha-qase-reporter --reporter-options extraReporters=spec --parallel
|
|
293
293
|
```
|
|
294
294
|
|
|
295
|
-
####
|
|
295
|
+
#### qase.config.json
|
|
296
296
|
|
|
297
297
|
```json
|
|
298
298
|
{
|
|
299
|
-
"
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
#### Multiple Reporters
|
|
307
|
-
|
|
308
|
-
```json
|
|
309
|
-
{
|
|
310
|
-
"reporter": "mocha-qase-reporter",
|
|
311
|
-
"reporterOptions": {
|
|
312
|
-
"extraReporters": ["spec", "json"]
|
|
313
|
-
}
|
|
314
|
-
}
|
|
315
|
-
```
|
|
316
|
-
|
|
317
|
-
#### Reporters with Options
|
|
318
|
-
|
|
319
|
-
```json
|
|
320
|
-
{
|
|
321
|
-
"reporter": "mocha-qase-reporter",
|
|
322
|
-
"reporterOptions": {
|
|
323
|
-
"extraReporters": [
|
|
324
|
-
"spec",
|
|
325
|
-
{
|
|
326
|
-
"name": "json",
|
|
327
|
-
"options": {
|
|
328
|
-
"output": "results.json"
|
|
329
|
-
}
|
|
299
|
+
"extraReporters": [
|
|
300
|
+
"spec",
|
|
301
|
+
{
|
|
302
|
+
"name": "json",
|
|
303
|
+
"options": {
|
|
304
|
+
"output": "results.json"
|
|
330
305
|
}
|
|
331
|
-
|
|
306
|
+
}
|
|
307
|
+
],
|
|
308
|
+
"testops": {
|
|
309
|
+
"api": {
|
|
310
|
+
"token": "your-api-token"
|
|
311
|
+
},
|
|
312
|
+
"project": "your-project"
|
|
332
313
|
}
|
|
333
314
|
}
|
|
334
315
|
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mocha-qase-reporter",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.7",
|
|
4
4
|
"description": "Mocha Cypress Reporter",
|
|
5
5
|
"homepage": "https://github.com/qase-tms/qase-javascript",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -41,19 +41,19 @@
|
|
|
41
41
|
"author": "Qase Team <support@qase.io>",
|
|
42
42
|
"license": "Apache-2.0",
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"mocha": "^11.
|
|
44
|
+
"mocha": "^11.7.5",
|
|
45
45
|
"deasync-promise": "^1.0.1",
|
|
46
|
-
"qase-javascript-commons": "~2.4.
|
|
46
|
+
"qase-javascript-commons": "~2.4.10",
|
|
47
47
|
"uuid": "^9.0.1"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
50
|
"@types/deasync-promise": "^1.0.2",
|
|
51
|
-
"@types/mocha": "^10.0.
|
|
52
|
-
"@types/node": "^20.
|
|
53
|
-
"@types/request": "^2.48.
|
|
54
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
|
55
|
-
"@typescript-eslint/parser": "^5.
|
|
56
|
-
"eslint": "^8.
|
|
51
|
+
"@types/mocha": "^10.0.10",
|
|
52
|
+
"@types/node": "^20.19.25",
|
|
53
|
+
"@types/request": "^2.48.13",
|
|
54
|
+
"@typescript-eslint/eslint-plugin": "^5.62.0",
|
|
55
|
+
"@typescript-eslint/parser": "^5.62.0",
|
|
56
|
+
"eslint": "^8.57.1",
|
|
57
57
|
"prettier": "^2.8.8"
|
|
58
58
|
}
|
|
59
59
|
}
|