mocha-qase-reporter 1.0.0-beta.1 → 1.0.0-beta.3
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 +27 -0
- package/changelog.md +19 -0
- package/dist/parallel.d.ts +1 -0
- package/dist/parallel.js +21 -0
- package/dist/reporter.d.ts +1 -0
- package/dist/reporter.js +21 -2
- package/dist/types.d.ts +2 -0
- package/dist/types.js +1 -0
- package/package.json +2 -2
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,22 @@
|
|
|
1
|
+
# qase-mocha@1.0.0-beta.3
|
|
2
|
+
|
|
3
|
+
## What's new
|
|
4
|
+
|
|
5
|
+
Support group parameters for test cases. You can specify the group parameters in the test case using the following format:
|
|
6
|
+
|
|
7
|
+
```ts
|
|
8
|
+
it('test', () => {
|
|
9
|
+
this.groupParameters({ param1: 'value1', param2: 'value2' });
|
|
10
|
+
expect(true).to.equal(true);
|
|
11
|
+
});
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
# qase-mocha@1.0.0-beta.2
|
|
15
|
+
|
|
16
|
+
## What's new
|
|
17
|
+
|
|
18
|
+
Support parallel execution of tests.
|
|
19
|
+
|
|
1
20
|
# qase-mocha@1.0.0-beta.1
|
|
2
21
|
|
|
3
22
|
## What's new
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/parallel.js
ADDED
|
@@ -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.d.ts
CHANGED
|
@@ -51,6 +51,7 @@ export declare class MochaQaseReporter extends reporters.Base {
|
|
|
51
51
|
qaseId: (id: number | number[]) => void;
|
|
52
52
|
title: (title: string) => void;
|
|
53
53
|
parameters: (values: Record<string, string>) => void;
|
|
54
|
+
groupParameters: (values: Record<string, string>) => void;
|
|
54
55
|
fields: (values: Record<string, string>) => void;
|
|
55
56
|
suite: (name: string) => void;
|
|
56
57
|
ignore: () => void;
|
package/dist/reporter.js
CHANGED
|
@@ -8,6 +8,8 @@ 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");
|
|
12
|
+
const uuid_1 = require("uuid");
|
|
11
13
|
const Events = mocha_1.Runner.constants;
|
|
12
14
|
class currentTest {
|
|
13
15
|
constructor() {
|
|
@@ -16,6 +18,8 @@ class currentTest {
|
|
|
16
18
|
this.attachments = [];
|
|
17
19
|
}
|
|
18
20
|
}
|
|
21
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-return,@typescript-eslint/restrict-template-expressions
|
|
22
|
+
const resolveParallelModeSetupFile = () => (0, node_path_1.join)(__dirname, `parallel${(0, node_path_1.extname)(__filename)}`);
|
|
19
23
|
class MochaQaseReporter extends mocha_1.reporters.Base {
|
|
20
24
|
constructor(runner, options, configLoader = new qase_javascript_commons_1.ConfigLoader()) {
|
|
21
25
|
super(runner, options);
|
|
@@ -47,6 +51,13 @@ class MochaQaseReporter extends mocha_1.reporters.Base {
|
|
|
47
51
|
}
|
|
48
52
|
this.metadata.parameters = stringRecord;
|
|
49
53
|
};
|
|
54
|
+
this.groupParameters = (values) => {
|
|
55
|
+
const stringRecord = {};
|
|
56
|
+
for (const [key, value] of Object.entries(values)) {
|
|
57
|
+
stringRecord[String(key)] = String(value);
|
|
58
|
+
}
|
|
59
|
+
this.metadata.groupParameters = stringRecord;
|
|
60
|
+
};
|
|
50
61
|
this.fields = (values) => {
|
|
51
62
|
const stringRecord = {};
|
|
52
63
|
for (const [key, value] of Object.entries(values)) {
|
|
@@ -104,7 +115,13 @@ class MochaQaseReporter extends mocha_1.reporters.Base {
|
|
|
104
115
|
frameworkName: 'mocha',
|
|
105
116
|
reporterName: 'mocha-qase-reporter',
|
|
106
117
|
});
|
|
107
|
-
|
|
118
|
+
if (options.parallel) {
|
|
119
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
120
|
+
options.require = [...(options.require ?? []), resolveParallelModeSetupFile()];
|
|
121
|
+
}
|
|
122
|
+
else {
|
|
123
|
+
this.applyListeners();
|
|
124
|
+
}
|
|
108
125
|
}
|
|
109
126
|
onStartRun() {
|
|
110
127
|
this.reporter.startTestRun();
|
|
@@ -118,6 +135,7 @@ class MochaQaseReporter extends mocha_1.reporters.Base {
|
|
|
118
135
|
ctx.qaseId = this.qaseId;
|
|
119
136
|
ctx.title = this.title;
|
|
120
137
|
ctx.parameters = this.parameters;
|
|
138
|
+
ctx.groupParameters = this.groupParameters;
|
|
121
139
|
ctx.fields = this.fields;
|
|
122
140
|
ctx.suite = this.suite;
|
|
123
141
|
ctx.ignore = this.ignore;
|
|
@@ -160,11 +178,12 @@ class MochaQaseReporter extends mocha_1.reporters.Base {
|
|
|
160
178
|
message: message ?? null,
|
|
161
179
|
muted: false,
|
|
162
180
|
params: this.metadata.parameters ?? {},
|
|
181
|
+
group_params: this.metadata.groupParameters ?? {},
|
|
163
182
|
relations: relations,
|
|
164
183
|
run_id: null,
|
|
165
184
|
signature: this.getSignature(test, ids),
|
|
166
185
|
steps: this.currentTest.steps,
|
|
167
|
-
id:
|
|
186
|
+
id: (0, uuid_1.v4)(),
|
|
168
187
|
execution: {
|
|
169
188
|
status: test.state
|
|
170
189
|
? MochaQaseReporter.statusMap[test.state]
|
package/dist/types.d.ts
CHANGED
|
@@ -16,6 +16,7 @@ export interface Methods {
|
|
|
16
16
|
qaseId(id: number | number[]): void;
|
|
17
17
|
title(title: string): void;
|
|
18
18
|
parameters(values: Record<string, string>): void;
|
|
19
|
+
groupParameters(values: Record<string, string>): void;
|
|
19
20
|
fields(values: Record<string, string>): void;
|
|
20
21
|
suite(name: string): void;
|
|
21
22
|
ignore(): void;
|
|
@@ -33,6 +34,7 @@ export declare class Metadata {
|
|
|
33
34
|
title?: string;
|
|
34
35
|
fields?: Record<string, string>;
|
|
35
36
|
parameters?: Record<string, string>;
|
|
37
|
+
groupParameters?: Record<string, string>;
|
|
36
38
|
ignore?: boolean;
|
|
37
39
|
suite?: string;
|
|
38
40
|
comment?: string;
|
package/dist/types.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mocha-qase-reporter",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.3",
|
|
4
4
|
"description": "Mocha Cypress Reporter",
|
|
5
5
|
"homepage": "https://github.com/qase-tms/qase-javascript",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"dependencies": {
|
|
43
43
|
"mocha": "^10.2.0",
|
|
44
44
|
"deasync-promise": "^1.0.1",
|
|
45
|
-
"qase-javascript-commons": "
|
|
45
|
+
"qase-javascript-commons": "~2.2.0",
|
|
46
46
|
"uuid": "^9.0.1"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|