mocha-qase-reporter 1.1.5 → 1.1.6

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 CHANGED
@@ -1,3 +1,9 @@
1
+ # qase-mocha@1.1.6
2
+
3
+ ## What's new
4
+
5
+ - Improved the handling of extra reporters in the reporter.
6
+
1
7
  # qase-mocha@1.1.5
2
8
 
3
9
  ## What's new
@@ -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
  */
@@ -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 (!reporterOptions) {
14
- return undefined;
15
- }
16
- // Handle different formats of extraReporters
17
- if (typeof reporterOptions['extraReporters'] === 'string') {
18
- return reporterOptions['extraReporters'];
19
- }
20
- if (Array.isArray(reporterOptions['extraReporters'])) {
21
- return reporterOptions['extraReporters'];
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
- if (typeof reporterOptions['extraReporters'] === 'object' && reporterOptions['extraReporters'] !== null) {
24
- return reporterOptions['extraReporters'];
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,23 @@ function createExtraReporters(runner, options, extraReportersConfig) {
68
80
  }
69
81
  }
70
82
  if (ReporterClass && typeof ReporterClass === 'function') {
71
- // Create reporter instance with options
72
- const reporterOptionsForMocha = { ...options, ...reporterOptions };
73
- const reporter = new ReporterClass(runner, reporterOptionsForMocha);
83
+ // Create reporter instance with clean options (without main reporter options)
84
+ const cleanOptions = {
85
+ ...options,
86
+ // Remove main reporter specific options
87
+ reporter: undefined,
88
+ reporterOptions: undefined,
89
+ 'reporter-option': undefined,
90
+ reporterOption: undefined,
91
+ // Add extra reporter specific options
92
+ ...reporterOptions
93
+ };
94
+ // Special handling for JSON reporter
95
+ if (reporterName === 'json' && reporterOptions['output']) {
96
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
97
+ cleanOptions.reporterOption = { output: reporterOptions['output'] };
98
+ }
99
+ const reporter = new ReporterClass(runner, cleanOptions);
74
100
  reporters.push(reporter);
75
101
  }
76
102
  }
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',
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 reporter options:
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
- #### Configuration File
295
+ #### qase.config.json
296
296
 
297
297
  ```json
298
298
  {
299
- "reporter": "mocha-qase-reporter",
300
- "reporterOptions": {
301
- "extraReporters": "spec"
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.5",
3
+ "version": "1.1.6",
4
4
  "description": "Mocha Cypress Reporter",
5
5
  "homepage": "https://github.com/qase-tms/qase-javascript",
6
6
  "sideEffects": false,