wdio-qase-reporter 1.0.0-beta.2 → 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 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,53 @@
1
+ # qase-wdio@1.0.0-beta.3
2
+
3
+ ## What's new
4
+
5
+ - Fix an issue with `cucumber` steps. Now, the reporter will correctly handle the `cucumber` steps and will report them
6
+ to the Qase TMS.
7
+ - Fix an issue with duplicate test runs. Now, the reporter will correctly handle the test runs and will not create
8
+ duplicate test runs in the Qase TMS.
9
+
10
+ You need to add `beforeRunHook` hook to the `onPrepare` and `afterRunHook` hook to the `onComplete` in the
11
+ `wdio.conf.ts` configuration file:
12
+
13
+ ```ts
14
+ import type { Options } from '@wdio/types'
15
+ import WDIOQaseReporter from "wdio-qase-reporter";
16
+ import { afterRunHook, beforeRunHook } from "wdio-qase-reporter";
17
+
18
+ export const config: Options.Testrunner = {
19
+ // ...
20
+ //
21
+ // =====
22
+ // Hooks
23
+ // =====
24
+ // WebdriverIO provides several hooks you can use to interfere with the test process in order to enhance
25
+ // it and to build services around it. You can either apply a single function or an array of
26
+ // methods to it. If one of them returns with a promise, WebdriverIO will wait until that promise got
27
+ // resolved to continue.
28
+ /**
29
+ * Gets executed once before all workers get launched.
30
+ * @param {object} config wdio configuration object
31
+ * @param {Array.<Object>} capabilities list of capabilities details
32
+ */
33
+ onPrepare: async function() {
34
+ await beforeRunHook();
35
+ },
36
+
37
+ /**
38
+ * Gets executed after all workers got shut down and the process is about to exit. An error
39
+ * thrown in the onComplete hook will result in the test run failing.
40
+ * @param {object} exitCode 0 - success, 1 - fail
41
+ * @param {object} config wdio configuration object
42
+ * @param {Array.<Object>} capabilities list of capabilities details
43
+ * @param {<Object>} results object containing test results
44
+ */
45
+ onComplete: async function() {
46
+ await afterRunHook();
47
+ },
48
+ }
49
+ ```
50
+
1
51
  # qase-wdio@1.0.0-beta.2
2
52
 
3
53
  ## What's new
@@ -0,0 +1,2 @@
1
+ export declare function beforeRunHook(): Promise<void>;
2
+ export declare function afterRunHook(): Promise<void>;
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
@@ -1,3 +1,4 @@
1
1
  import WDIOQaseReporter from './reporter.js';
2
2
  export * from './wdio';
3
+ export * from './hooks';
3
4
  export default WDIOQaseReporter;
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;
@@ -33,10 +33,11 @@ export default class WDIOQaseReporter extends WDIOReporter {
33
33
  * @private
34
34
  */
35
35
  private static transformError;
36
- onTestEnd(test: TestStats): Promise<void>;
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.publish();
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 onTestEnd(test) {
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) {
155
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
+ }
156
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);
157
154
  }
155
+ async onTestFail(test) {
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
+ }
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);
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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wdio-qase-reporter",
3
- "version": "1.0.0-beta.2",
3
+ "version": "1.0.0-beta.3",
4
4
  "description": "Qase WebDriverIO Reporter",
5
5
  "homepage": "https://github.com/qase-tms/qase-javascript",
6
6
  "sideEffects": false,