mocha-qase-reporter 1.0.0-beta.1 → 1.0.0-beta.2

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/README.md CHANGED
@@ -65,6 +65,33 @@ A test run will be performed and available at:
65
65
  https://app.qase.io/run/QASE_PROJECT_CODE
66
66
  ```
67
67
 
68
+ ### Parallel execution
69
+
70
+ The reporter supports parallel execution of tests.
71
+
72
+ First, you need to create a new run in Qase.io. You can use
73
+ the [Qase CLI](https://github.com/qase-tms/qasectl):
74
+
75
+ ```bash
76
+ # Create a new test run
77
+ qli testops run create --project DEMO --token token --title 'Mocha test run'
78
+
79
+ # Save the run ID to the environment variable
80
+ export QASE_TESTOPS_RUN_ID=$(< qase.env grep QASE_TESTOPS_RUN_ID | cut -d'=' -f2)
81
+ ```
82
+
83
+ Then, you can run tests in parallel:
84
+
85
+ ```bash
86
+ QASE_MODE=testops mocha --parallel
87
+ ```
88
+
89
+ After the tests are finished, you can complete the run:
90
+
91
+ ```bash
92
+ qli testops run complete --project DEMO --token token --run $(echo $QASE_TESTOPS_RUN_ID)
93
+ ```
94
+
68
95
  ## Configuration
69
96
 
70
97
  Qase Mocha reporter can be configured in multiple ways:
package/changelog.md CHANGED
@@ -1,3 +1,9 @@
1
+ # qase-mocha@1.0.0-beta.2
2
+
3
+ ## What's new
4
+
5
+ Support parallel execution of tests.
6
+
1
7
  # qase-mocha@1.0.0-beta.1
2
8
 
3
9
  ## What's new
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
7
+ // @ts-ignore
8
+ const parallel_buffered_js_1 = __importDefault(require("mocha/lib/nodejs/reporters/parallel-buffered.js"));
9
+ const reporter_js_1 = require("./reporter.js");
10
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
11
+ const originalCreateListeners =
12
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
13
+ parallel_buffered_js_1.default.prototype.createListeners;
14
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
15
+ parallel_buffered_js_1.default.prototype.createListeners = function (runner) {
16
+ console.log("createListeners");
17
+ const result = originalCreateListeners.call(this, runner);
18
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
19
+ new reporter_js_1.MochaQaseReporter(runner, this.options);
20
+ return result;
21
+ };
package/dist/reporter.js CHANGED
@@ -8,6 +8,7 @@ const mocha_1 = require("mocha");
8
8
  const types_1 = require("./types");
9
9
  const qase_javascript_commons_1 = require("qase-javascript-commons");
10
10
  const deasync_promise_1 = __importDefault(require("deasync-promise"));
11
+ const node_path_1 = require("node:path");
11
12
  const Events = mocha_1.Runner.constants;
12
13
  class currentTest {
13
14
  constructor() {
@@ -16,6 +17,8 @@ class currentTest {
16
17
  this.attachments = [];
17
18
  }
18
19
  }
20
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-return,@typescript-eslint/restrict-template-expressions
21
+ const resolveParallelModeSetupFile = () => (0, node_path_1.join)(__dirname, `parallel${(0, node_path_1.extname)(__filename)}`);
19
22
  class MochaQaseReporter extends mocha_1.reporters.Base {
20
23
  constructor(runner, options, configLoader = new qase_javascript_commons_1.ConfigLoader()) {
21
24
  super(runner, options);
@@ -104,7 +107,12 @@ class MochaQaseReporter extends mocha_1.reporters.Base {
104
107
  frameworkName: 'mocha',
105
108
  reporterName: 'mocha-qase-reporter',
106
109
  });
107
- this.applyListeners();
110
+ if (options.parallel) {
111
+ options.require = [...(options.require ?? []), resolveParallelModeSetupFile()];
112
+ }
113
+ else {
114
+ this.applyListeners();
115
+ }
108
116
  }
109
117
  onStartRun() {
110
118
  this.reporter.startTestRun();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mocha-qase-reporter",
3
- "version": "1.0.0-beta.1",
3
+ "version": "1.0.0-beta.2",
4
4
  "description": "Mocha Cypress Reporter",
5
5
  "homepage": "https://github.com/qase-tms/qase-javascript",
6
6
  "sideEffects": false,