wdio-qase-reporter 1.0.0-beta.2 → 1.0.0-beta.4
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 +12 -0
- package/changelog.md +61 -0
- package/dist/hooks.d.ts +2 -0
- package/dist/hooks.js +31 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/reporter.d.ts +4 -3
- package/dist/reporter.js +32 -28
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -117,6 +117,7 @@ Also, you need to configure the reporter using the `wdio.conf.ts` file:
|
|
|
117
117
|
// wdio.conf.ts
|
|
118
118
|
import WDIOQaseReporter from 'wdio-qase-reporter';
|
|
119
119
|
import type { Options } from '@wdio/types';
|
|
120
|
+
import { afterRunHook, beforeRunHook } from 'wdio-qase-reporter';
|
|
120
121
|
|
|
121
122
|
export const config: Options.Testrunner = {
|
|
122
123
|
reporters: [[WDIOQaseReporter, {
|
|
@@ -124,6 +125,17 @@ export const config: Options.Testrunner = {
|
|
|
124
125
|
disableWebdriverScreenshotsReporting: true,
|
|
125
126
|
useCucumber: false,
|
|
126
127
|
}]],
|
|
128
|
+
|
|
129
|
+
// ...
|
|
130
|
+
// =====
|
|
131
|
+
// Hooks
|
|
132
|
+
// =====
|
|
133
|
+
onPrepare: async function() {
|
|
134
|
+
await beforeRunHook();
|
|
135
|
+
},
|
|
136
|
+
onComplete: async function() {
|
|
137
|
+
await afterRunHook();
|
|
138
|
+
},
|
|
127
139
|
// ... other options
|
|
128
140
|
};
|
|
129
141
|
```
|
package/changelog.md
CHANGED
|
@@ -1,3 +1,64 @@
|
|
|
1
|
+
# qase-wdio@1.0.0-beta.4
|
|
2
|
+
|
|
3
|
+
## What's new
|
|
4
|
+
|
|
5
|
+
Fix an issue with attaching the screenshot to the test case. Now, the reporter will correctly handle the screenshots and
|
|
6
|
+
will attach them to the test case in the Qase TMS.
|
|
7
|
+
|
|
8
|
+
```log
|
|
9
|
+
The first argument must be of type string or an instance of Buffer, ArrayBuffer, or Array or an Array-like Object. Received an instance of Object
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
# qase-wdio@1.0.0-beta.3
|
|
13
|
+
|
|
14
|
+
## What's new
|
|
15
|
+
|
|
16
|
+
- Fix an issue with `cucumber` steps. Now, the reporter will correctly handle the `cucumber` steps and will report them
|
|
17
|
+
to the Qase TMS.
|
|
18
|
+
- Fix an issue with duplicate test runs. Now, the reporter will correctly handle the test runs and will not create
|
|
19
|
+
duplicate test runs in the Qase TMS.
|
|
20
|
+
|
|
21
|
+
You need to add `beforeRunHook` hook to the `onPrepare` and `afterRunHook` hook to the `onComplete` in the
|
|
22
|
+
`wdio.conf.ts` configuration file:
|
|
23
|
+
|
|
24
|
+
```ts
|
|
25
|
+
import type { Options } from '@wdio/types'
|
|
26
|
+
import WDIOQaseReporter from "wdio-qase-reporter";
|
|
27
|
+
import { afterRunHook, beforeRunHook } from "wdio-qase-reporter";
|
|
28
|
+
|
|
29
|
+
export const config: Options.Testrunner = {
|
|
30
|
+
// ...
|
|
31
|
+
//
|
|
32
|
+
// =====
|
|
33
|
+
// Hooks
|
|
34
|
+
// =====
|
|
35
|
+
// WebdriverIO provides several hooks you can use to interfere with the test process in order to enhance
|
|
36
|
+
// it and to build services around it. You can either apply a single function or an array of
|
|
37
|
+
// methods to it. If one of them returns with a promise, WebdriverIO will wait until that promise got
|
|
38
|
+
// resolved to continue.
|
|
39
|
+
/**
|
|
40
|
+
* Gets executed once before all workers get launched.
|
|
41
|
+
* @param {object} config wdio configuration object
|
|
42
|
+
* @param {Array.<Object>} capabilities list of capabilities details
|
|
43
|
+
*/
|
|
44
|
+
onPrepare: async function() {
|
|
45
|
+
await beforeRunHook();
|
|
46
|
+
},
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Gets executed after all workers got shut down and the process is about to exit. An error
|
|
50
|
+
* thrown in the onComplete hook will result in the test run failing.
|
|
51
|
+
* @param {object} exitCode 0 - success, 1 - fail
|
|
52
|
+
* @param {object} config wdio configuration object
|
|
53
|
+
* @param {Array.<Object>} capabilities list of capabilities details
|
|
54
|
+
* @param {<Object>} results object containing test results
|
|
55
|
+
*/
|
|
56
|
+
onComplete: async function() {
|
|
57
|
+
await afterRunHook();
|
|
58
|
+
},
|
|
59
|
+
}
|
|
60
|
+
```
|
|
61
|
+
|
|
1
62
|
# qase-wdio@1.0.0-beta.2
|
|
2
63
|
|
|
3
64
|
## What's new
|
package/dist/hooks.d.ts
ADDED
package/dist/hooks.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.afterRunHook = exports.beforeRunHook = void 0;
|
|
4
|
+
const qase_javascript_commons_1 = require("qase-javascript-commons");
|
|
5
|
+
async function beforeRunHook() {
|
|
6
|
+
const configLoader = new qase_javascript_commons_1.ConfigLoader();
|
|
7
|
+
const config = configLoader.load();
|
|
8
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
9
|
+
const reporter = qase_javascript_commons_1.QaseReporter.getInstance({
|
|
10
|
+
...config,
|
|
11
|
+
frameworkPackage: 'wdio',
|
|
12
|
+
frameworkName: 'wdio',
|
|
13
|
+
reporterName: 'wdio-qase-reporter',
|
|
14
|
+
});
|
|
15
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
|
|
16
|
+
await reporter.startTestRunAsync();
|
|
17
|
+
}
|
|
18
|
+
exports.beforeRunHook = beforeRunHook;
|
|
19
|
+
async function afterRunHook() {
|
|
20
|
+
const configLoader = new qase_javascript_commons_1.ConfigLoader();
|
|
21
|
+
const config = configLoader.load();
|
|
22
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
23
|
+
const reporter = qase_javascript_commons_1.QaseReporter.getInstance({
|
|
24
|
+
...config,
|
|
25
|
+
frameworkPackage: 'wdio',
|
|
26
|
+
frameworkName: 'wdio',
|
|
27
|
+
reporterName: 'wdio-qase-reporter',
|
|
28
|
+
});
|
|
29
|
+
await reporter.complete();
|
|
30
|
+
}
|
|
31
|
+
exports.afterRunHook = afterRunHook;
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -19,4 +19,5 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
19
19
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
20
|
const reporter_js_1 = __importDefault(require("./reporter.js"));
|
|
21
21
|
__exportStar(require("./wdio"), exports);
|
|
22
|
+
__exportStar(require("./hooks"), exports);
|
|
22
23
|
exports.default = reporter_js_1.default;
|
package/dist/reporter.d.ts
CHANGED
|
@@ -33,10 +33,11 @@ export default class WDIOQaseReporter extends WDIOReporter {
|
|
|
33
33
|
* @private
|
|
34
34
|
*/
|
|
35
35
|
private static transformError;
|
|
36
|
-
|
|
36
|
+
onTestPass(): Promise<void>;
|
|
37
|
+
onTestRetry(test: TestStats): Promise<void>;
|
|
38
|
+
onTestFail(test: TestStats): Promise<void>;
|
|
39
|
+
onTestSkip(test: TestStats): Promise<void>;
|
|
37
40
|
private _endTest;
|
|
38
|
-
onHookStart(): void;
|
|
39
|
-
onHookEnd(): void;
|
|
40
41
|
onBeforeCommand(command: BeforeCommandArgs): void;
|
|
41
42
|
onAfterCommand(command: AfterCommandArgs): void;
|
|
42
43
|
registerListeners(): void;
|
package/dist/reporter.js
CHANGED
|
@@ -38,7 +38,7 @@ class WDIOQaseReporter extends reporter_1.default {
|
|
|
38
38
|
}
|
|
39
39
|
onRunnerStart(runner) {
|
|
40
40
|
this._isMultiremote = runner.isMultiremote;
|
|
41
|
-
this.reporter.startTestRun();
|
|
41
|
+
// this.reporter.startTestRun();
|
|
42
42
|
this.isSync = false;
|
|
43
43
|
}
|
|
44
44
|
onSuiteStart(suite) {
|
|
@@ -69,20 +69,6 @@ class WDIOQaseReporter extends reporter_1.default {
|
|
|
69
69
|
case '@suite':
|
|
70
70
|
this.addSuite({ suite: tagData.value });
|
|
71
71
|
break;
|
|
72
|
-
// case 'parameters':
|
|
73
|
-
// const params = tagData.value.split(',').map((param) => {
|
|
74
|
-
// const [key, value] = param.split(':');
|
|
75
|
-
// return { key, value };
|
|
76
|
-
// });
|
|
77
|
-
// process.emit(events.addParameters, { records: params });
|
|
78
|
-
// break;
|
|
79
|
-
// case 'fields':
|
|
80
|
-
// const fields = tagData.value.split(',').map((field) => {
|
|
81
|
-
// const [key, value] = field.split(':');
|
|
82
|
-
// return { key, value };
|
|
83
|
-
// });
|
|
84
|
-
// process.emit(events.addFields, { records: fields });
|
|
85
|
-
// break;
|
|
86
72
|
}
|
|
87
73
|
}
|
|
88
74
|
return;
|
|
@@ -120,7 +106,7 @@ class WDIOQaseReporter extends reporter_1.default {
|
|
|
120
106
|
this.storage.clear();
|
|
121
107
|
}
|
|
122
108
|
async onRunnerEnd(_) {
|
|
123
|
-
await this.reporter.
|
|
109
|
+
await this.reporter.sendResults();
|
|
124
110
|
this.isSync = true;
|
|
125
111
|
}
|
|
126
112
|
onTestStart(test) {
|
|
@@ -151,10 +137,36 @@ class WDIOQaseReporter extends reporter_1.default {
|
|
|
151
137
|
}
|
|
152
138
|
return err;
|
|
153
139
|
}
|
|
154
|
-
async
|
|
140
|
+
async onTestPass() {
|
|
141
|
+
if (this._options.useCucumber) {
|
|
142
|
+
this._endStep();
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
await this._endTest(qase_javascript_commons_1.TestStatusEnum.passed, null);
|
|
146
|
+
}
|
|
147
|
+
async onTestRetry(test) {
|
|
148
|
+
const error = test.errors ? WDIOQaseReporter.transformError(test.errors) : null;
|
|
149
|
+
if (this._options.useCucumber) {
|
|
150
|
+
this._endStep(error ? qase_javascript_commons_1.TestStatusEnum.failed : qase_javascript_commons_1.TestStatusEnum.passed);
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
await this._endTest(WDIOQaseReporter.statusMap[test.state] ?? qase_javascript_commons_1.TestStatusEnum.skipped, error, test.end ? test.end.valueOf() / 1000 : Date.now().valueOf() / 1000);
|
|
154
|
+
}
|
|
155
|
+
async onTestFail(test) {
|
|
155
156
|
const error = test.errors ? WDIOQaseReporter.transformError(test.errors) : null;
|
|
157
|
+
if (this._options.useCucumber) {
|
|
158
|
+
this._endStep(qase_javascript_commons_1.TestStatusEnum.failed);
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
156
161
|
await this._endTest(WDIOQaseReporter.statusMap[test.state] ?? qase_javascript_commons_1.TestStatusEnum.skipped, error, test.end ? test.end.valueOf() / 1000 : Date.now().valueOf() / 1000);
|
|
157
162
|
}
|
|
163
|
+
async onTestSkip(test) {
|
|
164
|
+
if (this._options.useCucumber) {
|
|
165
|
+
this._endStep(qase_javascript_commons_1.TestStatusEnum.skipped);
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
await this._endTest(WDIOQaseReporter.statusMap[test.state] ?? qase_javascript_commons_1.TestStatusEnum.skipped, null);
|
|
169
|
+
}
|
|
158
170
|
async _endTest(status, err, end_time = Date.now().valueOf() / 1000) {
|
|
159
171
|
const testResult = this.storage.getCurrentTest();
|
|
160
172
|
if (testResult === undefined || this.storage.ignore) {
|
|
@@ -180,15 +192,8 @@ class WDIOQaseReporter extends reporter_1.default {
|
|
|
180
192
|
testResult.message = err === null ?
|
|
181
193
|
null : err.message === undefined ?
|
|
182
194
|
null : err.message;
|
|
183
|
-
console.log(testResult);
|
|
184
195
|
await this.reporter.addTestResult(testResult);
|
|
185
196
|
}
|
|
186
|
-
onHookStart() {
|
|
187
|
-
console.log('Hook started');
|
|
188
|
-
}
|
|
189
|
-
onHookEnd() {
|
|
190
|
-
console.log('Hook ended');
|
|
191
|
-
}
|
|
192
197
|
onBeforeCommand(command) {
|
|
193
198
|
if (!this.storage.getLastItem()) {
|
|
194
199
|
return;
|
|
@@ -209,11 +214,11 @@ class WDIOQaseReporter extends reporter_1.default {
|
|
|
209
214
|
}
|
|
210
215
|
onAfterCommand(command) {
|
|
211
216
|
const { disableWebdriverStepsReporting, disableWebdriverScreenshotsReporting } = this._options;
|
|
212
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
213
|
-
const commandResult = command.result || undefined;
|
|
217
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-unsafe-member-access
|
|
218
|
+
const commandResult = command.result.value || undefined;
|
|
214
219
|
const isScreenshot = (0, utils_1.isScreenshotCommand)(command);
|
|
215
220
|
if (!disableWebdriverScreenshotsReporting && isScreenshot && commandResult) {
|
|
216
|
-
this.attachFile('Screenshot', Buffer.from(commandResult, 'base64'), 'image/png');
|
|
221
|
+
this.attachFile('Screenshot.png', Buffer.from(commandResult, 'base64'), 'image/png');
|
|
217
222
|
}
|
|
218
223
|
if (disableWebdriverStepsReporting || this._isMultiremote || !this.storage.getCurrentStep()) {
|
|
219
224
|
return;
|
|
@@ -391,7 +396,6 @@ class WDIOQaseReporter extends reporter_1.default {
|
|
|
391
396
|
mime_type: contentType,
|
|
392
397
|
content: content,
|
|
393
398
|
};
|
|
394
|
-
console.log('attachFile:', attach);
|
|
395
399
|
this.storage.getLastItem()?.attachments.push(attach);
|
|
396
400
|
}
|
|
397
401
|
_endStep(status = qase_javascript_commons_1.TestStatusEnum.passed) {
|