wdio-qase-reporter 1.0.0-beta.1

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/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,145 @@
1
+ # Qase TMS WebDriverIO reporter
2
+
3
+ Publish results simple and easy.
4
+
5
+ To install the latest beta version, run:
6
+
7
+ ```sh
8
+ npm install -D wdio-qase-reporter@beta
9
+ ```
10
+
11
+ ## Getting started
12
+
13
+ The WebDriverIO reporter can auto-generate test cases
14
+ and suites from your test data.
15
+ Test results of subsequent test runs will match the same test cases
16
+ as long as their names and file paths don't change.
17
+
18
+ You can also annotate the tests with the IDs of existing test cases
19
+ from Qase.io before executing tests. It's a more reliable way to bind
20
+ autotests to test cases, that persists when you rename, move, or
21
+ parameterize your tests.
22
+
23
+ For example:
24
+
25
+ ### Mocha/Jasmine
26
+
27
+ ```typescript
28
+ import {qase} from "wdio-qase-reporter";
29
+
30
+ describe('My First Test', () => {
31
+ it('Several ids', () => {
32
+ qase.id(1);
33
+ expect(true).to.equal(true);
34
+ });
35
+
36
+ // a test can check multiple test cases
37
+ it('Correct test', () => {
38
+ qase.id([2, 3]);
39
+ expect(true).to.equal(true);
40
+ });
41
+
42
+ it('With steps',async () => {
43
+ await qase.step('Step 1', async (s1) => {
44
+ await s1.step('Step 1.1', async () => {
45
+ // do something
46
+ s1.attach({name: 'screenshot.png', type: 'image/png', content: await browser.takeScreenshot()})
47
+ })
48
+
49
+ qase.attach({name: 'log.txt', content: 'test', type: 'text/plain'})
50
+
51
+ await s1.step('Step 1.2', async () => {
52
+ // do something
53
+ })
54
+ })
55
+ expect(true).to.equal(true);
56
+ });
57
+ });
58
+ ```
59
+
60
+ ### Cucumber
61
+
62
+ ```gherkin
63
+ Feature: Test user role
64
+
65
+ @QaseId=3
66
+ Scenario: Login
67
+ Given I test login
68
+ ```
69
+
70
+ To execute WebDriverIO tests and report them to Qase.io, run the command:
71
+
72
+ ```bash
73
+ QASE_MODE=testops wdio run ./wdio.conf.ts
74
+ ```
75
+
76
+ <p align="center">
77
+ <img width="65%" src="./screenshots/screenshot.png">
78
+ </p>
79
+
80
+ A test run will be performed and available at:
81
+
82
+ ```
83
+ https://app.qase.io/run/QASE_PROJECT_CODE
84
+ ```
85
+
86
+ ## Configuration
87
+
88
+ Qase WebDriverIO reporter can be configured in multiple ways:
89
+
90
+ - using a separate config file `qase.config.json`,
91
+ - using environment variables (they override the values from the configuration files).
92
+
93
+ For a full list of configuration options, see
94
+ the [Configuration reference](../qase-javascript-commons/README.md#configuration).
95
+
96
+ Example `qase.config.json` config:
97
+
98
+ ```json
99
+ {
100
+ "mode": "testops",
101
+ "debug": true,
102
+ "testops": {
103
+ "api": {
104
+ "token": "api_key"
105
+ },
106
+ "project": "project_code",
107
+ "run": {
108
+ "complete": true
109
+ }
110
+ }
111
+ }
112
+ ```
113
+
114
+ Also, you need to configure the reporter using the `wdio.conf.ts` file:
115
+
116
+ ```ts
117
+ // wdio.conf.ts
118
+ import WDIOQaseReporter from 'wdio-qase-reporter';
119
+ import type { Options } from '@wdio/types';
120
+
121
+ export const config: Options.Testrunner = {
122
+ reporters: [[WDIOQaseReporter, {
123
+ disableWebdriverStepsReporting: true,
124
+ disableWebdriverScreenshotsReporting: true,
125
+ useCucumber: false,
126
+ }]],
127
+ // ... other options
128
+ };
129
+ ```
130
+
131
+ Additional options of the reporter in the `wdio.conf.ts` file:
132
+
133
+ - `disableWebdriverStepsReporting` - optional parameter(`false` by default), in order to log only custom steps to the reporter.
134
+ - `disableWebdriverScreenshotsReporting` - optional parameter(`false` by default), in order to not attach screenshots to the reporter.
135
+ - `useCucumber` - optional parameter (`false` by default), if you use Cucumber, set it to true
136
+
137
+ ## Requirements
138
+
139
+ We maintain the reporter on [LTS versions of Node](https://nodejs.org/en/about/releases/).
140
+
141
+ `wdio >= 8.40.0`
142
+
143
+ <!-- references -->
144
+
145
+ [auth]: https://developers.qase.io/#authentication
package/changelog.md ADDED
@@ -0,0 +1,5 @@
1
+ # qase-wdio@1.0.0-beta.1
2
+
3
+ ## What's new
4
+
5
+ First major beta release for the version 1 series of the Qase WebDriverIO reporter.
@@ -0,0 +1,12 @@
1
+ export declare const events: {
2
+ readonly addQaseID: "qase:id";
3
+ readonly addTitle: "qase:title";
4
+ readonly addFields: "qase:fields";
5
+ readonly addSuite: "qase:suite";
6
+ readonly addIgnore: "qase:ignore";
7
+ readonly addParameters: "qase:parameters";
8
+ readonly addAttachment: "qase:attachment";
9
+ readonly startStep: "qase:startStep";
10
+ readonly endStep: "qase:endStep";
11
+ readonly addStep: "qase:addStep";
12
+ };
package/dist/events.js ADDED
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.events = void 0;
4
+ exports.events = {
5
+ addQaseID: 'qase:id',
6
+ addTitle: 'qase:title',
7
+ addFields: 'qase:fields',
8
+ addSuite: 'qase:suite',
9
+ addIgnore: 'qase:ignore',
10
+ addParameters: 'qase:parameters',
11
+ addAttachment: 'qase:attachment',
12
+ startStep: 'qase:startStep',
13
+ endStep: 'qase:endStep',
14
+ addStep: 'qase:addStep',
15
+ };
@@ -0,0 +1,3 @@
1
+ import WDIOQaseReporter from './reporter.js';
2
+ export * from './wdio';
3
+ export default WDIOQaseReporter;
package/dist/index.js ADDED
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ var __importDefault = (this && this.__importDefault) || function (mod) {
17
+ return (mod && mod.__esModule) ? mod : { "default": mod };
18
+ };
19
+ Object.defineProperty(exports, "__esModule", { value: true });
20
+ const reporter_js_1 = __importDefault(require("./reporter.js"));
21
+ __exportStar(require("./wdio"), exports);
22
+ exports.default = reporter_js_1.default;
@@ -0,0 +1,18 @@
1
+ export interface AddQaseIdEventArgs {
2
+ ids: number[];
3
+ }
4
+ export interface AddRecordsEventArgs {
5
+ records: Record<string, string>;
6
+ }
7
+ export interface AddTitleEventArgs {
8
+ title: string;
9
+ }
10
+ export interface AddSuiteEventArgs {
11
+ suite: string;
12
+ }
13
+ export interface AddAttachmentEventArgs {
14
+ name?: string;
15
+ type?: string;
16
+ content?: string;
17
+ paths?: string[];
18
+ }
package/dist/models.js ADDED
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,6 @@
1
+ export declare class QaseReporterOptions {
2
+ useCucumber?: boolean;
3
+ disableWebdriverStepsReporting?: boolean;
4
+ disableWebdriverScreenshotsReporting?: boolean;
5
+ constructor();
6
+ }
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.QaseReporterOptions = void 0;
4
+ class QaseReporterOptions {
5
+ constructor() {
6
+ this.useCucumber = false;
7
+ this.disableWebdriverStepsReporting = false;
8
+ this.disableWebdriverScreenshotsReporting = false;
9
+ }
10
+ }
11
+ exports.QaseReporterOptions = QaseReporterOptions;
@@ -0,0 +1,57 @@
1
+ import WDIOReporter, { AfterCommandArgs, BeforeCommandArgs, RunnerStats, SuiteStats, TestStats } from '@wdio/reporter';
2
+ import { TestStatusEnum, TestStepType } from 'qase-javascript-commons';
3
+ import { AddAttachmentEventArgs, AddQaseIdEventArgs, AddRecordsEventArgs, AddSuiteEventArgs, AddTitleEventArgs } from './models';
4
+ export default class WDIOQaseReporter extends WDIOReporter {
5
+ /**
6
+ * @type {Record<string, TestStatusEnum>}
7
+ */
8
+ static statusMap: Record<string, TestStatusEnum>;
9
+ /**
10
+ * @type {ReporterInterface}
11
+ * @private
12
+ */
13
+ private reporter;
14
+ private storage;
15
+ /**
16
+ * @type {boolean}
17
+ * @private
18
+ */
19
+ private isSync;
20
+ private _options;
21
+ private _isMultiremote?;
22
+ constructor(options: any);
23
+ get isSynchronised(): boolean;
24
+ set isSynchronised(value: boolean);
25
+ onRunnerStart(runner: RunnerStats): void;
26
+ onSuiteStart(suite: SuiteStats): void;
27
+ onSuiteEnd(suite: SuiteStats): Promise<void>;
28
+ onRunnerEnd(_: RunnerStats): Promise<void>;
29
+ onTestStart(test: TestStats): void;
30
+ /**
31
+ * @param {Error[]} testErrors
32
+ * @returns {CompoundError}
33
+ * @private
34
+ */
35
+ private static transformError;
36
+ onTestEnd(test: TestStats): Promise<void>;
37
+ private _endTest;
38
+ onHookStart(): void;
39
+ onHookEnd(): void;
40
+ onBeforeCommand(command: BeforeCommandArgs): void;
41
+ onAfterCommand(command: AfterCommandArgs): void;
42
+ registerListeners(): void;
43
+ addQaseId({ ids }: AddQaseIdEventArgs): void;
44
+ addTitle({ title }: AddTitleEventArgs): void;
45
+ addSuite({ suite }: AddSuiteEventArgs): void;
46
+ addParameters({ records }: AddRecordsEventArgs): void;
47
+ addFields({ records }: AddRecordsEventArgs): void;
48
+ addAttachment({ name, type, content, paths }: AddAttachmentEventArgs): void;
49
+ ignore(): void;
50
+ addStep(step: TestStepType): void;
51
+ private _startTest;
52
+ private _startStep;
53
+ private attachJSON;
54
+ private attachFile;
55
+ private _endStep;
56
+ private parseTag;
57
+ }
@@ -0,0 +1,413 @@
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
+ const reporter_1 = __importDefault(require("@wdio/reporter"));
7
+ const qase_javascript_commons_1 = require("qase-javascript-commons");
8
+ const uuid_1 = require("uuid");
9
+ const storage_1 = require("./storage");
10
+ const options_1 = require("./options");
11
+ const utils_1 = require("./utils");
12
+ const path_1 = __importDefault(require("path"));
13
+ const events_1 = require("./events");
14
+ class WDIOQaseReporter extends reporter_1.default {
15
+ constructor(options) {
16
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
17
+ super(options);
18
+ const configLoader = new qase_javascript_commons_1.ConfigLoader();
19
+ const config = configLoader.load();
20
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
21
+ this.reporter = qase_javascript_commons_1.QaseReporter.getInstance({
22
+ ...(0, qase_javascript_commons_1.composeOptions)(options, config),
23
+ frameworkPackage: 'wdio',
24
+ frameworkName: 'wdio',
25
+ reporterName: 'wdio-qase-reporter',
26
+ });
27
+ this.isSync = true;
28
+ this.storage = new storage_1.Storage();
29
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
30
+ this._options = Object.assign(new options_1.QaseReporterOptions(), options);
31
+ this.registerListeners();
32
+ }
33
+ get isSynchronised() {
34
+ return this.isSync;
35
+ }
36
+ set isSynchronised(value) {
37
+ this.isSync = value;
38
+ }
39
+ onRunnerStart(runner) {
40
+ this._isMultiremote = runner.isMultiremote;
41
+ this.reporter.startTestRun();
42
+ this.isSync = false;
43
+ }
44
+ onSuiteStart(suite) {
45
+ this.storage.currentFile = suite.file;
46
+ if (this._options.useCucumber && suite.type === 'scenario') {
47
+ this._startTest(suite.title, suite.cid ?? '');
48
+ if (suite.tags === undefined) {
49
+ return;
50
+ }
51
+ const tags = suite.tags.map((tag) => {
52
+ return tag.name;
53
+ });
54
+ for (const tag of tags) {
55
+ if (!tag.includes('=')) {
56
+ continue;
57
+ }
58
+ const tagData = this.parseTag(tag);
59
+ if (tagData === null) {
60
+ continue;
61
+ }
62
+ switch (tagData.key.toLowerCase()) {
63
+ case '@qaseid':
64
+ this.addQaseId({ ids: tagData.value.split(',').map((id) => parseInt(id)) });
65
+ break;
66
+ case '@title':
67
+ this.addTitle({ title: tagData.value });
68
+ break;
69
+ case '@suite':
70
+ this.addSuite({ suite: tagData.value });
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
+ }
87
+ }
88
+ return;
89
+ }
90
+ this.storage.suites.push(suite.title);
91
+ }
92
+ async onSuiteEnd(suite) {
93
+ this.storage.currentFile = undefined;
94
+ if (this._options.useCucumber && suite.type === 'scenario') {
95
+ suite.hooks = suite.hooks.map((hook) => {
96
+ hook.state = hook.state ?? 'passed';
97
+ return hook;
98
+ });
99
+ const suiteChildren = [...suite.tests, ...suite.hooks];
100
+ const isSkipped = suite.tests.every(item => ['skipped'].includes(item.state))
101
+ && suite.hooks.every(item => ['passed', 'skipped'].includes(item.state ?? 'passed'));
102
+ if (isSkipped) {
103
+ await this._endTest(qase_javascript_commons_1.TestStatusEnum.skipped, null);
104
+ return;
105
+ }
106
+ const isFailed = suiteChildren.find(item => item.state === 'failed');
107
+ if (isFailed) {
108
+ const err = WDIOQaseReporter.transformError(isFailed.errors ?? []);
109
+ await this._endTest(qase_javascript_commons_1.TestStatusEnum.failed, err);
110
+ return;
111
+ }
112
+ const isPassed = suiteChildren.every(item => item.state === 'passed');
113
+ const isPartiallySkipped = suiteChildren.every(item => ['passed', 'skipped'].includes(item.state ?? 'passed'));
114
+ if (isPassed || isPartiallySkipped) {
115
+ await this._endTest(qase_javascript_commons_1.TestStatusEnum.passed, null);
116
+ return;
117
+ }
118
+ return;
119
+ }
120
+ this.storage.clear();
121
+ }
122
+ async onRunnerEnd(_) {
123
+ await this.reporter.publish();
124
+ this.isSync = true;
125
+ }
126
+ onTestStart(test) {
127
+ if (this._options.useCucumber) {
128
+ this._startStep(test.title);
129
+ return;
130
+ }
131
+ this._startTest(test.title, test.cid, test.start.valueOf() / 1000);
132
+ }
133
+ /**
134
+ * @param {Error[]} testErrors
135
+ * @returns {CompoundError}
136
+ * @private
137
+ */
138
+ static transformError(testErrors) {
139
+ const err = new qase_javascript_commons_1.CompoundError();
140
+ for (const error of testErrors) {
141
+ if (error.message == undefined) {
142
+ continue;
143
+ }
144
+ err.addMessage(error.message);
145
+ }
146
+ for (const error of testErrors) {
147
+ if (error.stack == undefined) {
148
+ continue;
149
+ }
150
+ err.addStacktrace(error.stack);
151
+ }
152
+ return err;
153
+ }
154
+ async onTestEnd(test) {
155
+ const error = test.errors ? WDIOQaseReporter.transformError(test.errors) : null;
156
+ 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
+ }
158
+ async _endTest(status, err, end_time = Date.now().valueOf() / 1000) {
159
+ const testResult = this.storage.getCurrentTest();
160
+ if (testResult === undefined || this.storage.ignore) {
161
+ return;
162
+ }
163
+ const relations = {};
164
+ if (this.storage.suites.length > 0) {
165
+ relations.suite = {
166
+ data: this.storage.suites.map((suite) => {
167
+ return {
168
+ title: suite,
169
+ public_id: null,
170
+ };
171
+ }),
172
+ };
173
+ }
174
+ testResult.relations = relations;
175
+ testResult.execution.duration = testResult.execution.start_time ? Math.round(end_time - testResult.execution.start_time) : 0;
176
+ testResult.execution.status = status;
177
+ testResult.execution.stacktrace = err === null ?
178
+ null : err.stacktrace === undefined ?
179
+ null : err.stacktrace;
180
+ testResult.message = err === null ?
181
+ null : err.message === undefined ?
182
+ null : err.message;
183
+ console.log(testResult);
184
+ await this.reporter.addTestResult(testResult);
185
+ }
186
+ onHookStart() {
187
+ console.log('Hook started');
188
+ }
189
+ onHookEnd() {
190
+ console.log('Hook ended');
191
+ }
192
+ onBeforeCommand(command) {
193
+ if (!this.storage.getLastItem()) {
194
+ return;
195
+ }
196
+ const { disableWebdriverStepsReporting } = this._options;
197
+ if (disableWebdriverStepsReporting || this._isMultiremote) {
198
+ return;
199
+ }
200
+ const { method, endpoint } = command;
201
+ // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
202
+ const stepName = command.command ? command.command : `${method} ${endpoint}`;
203
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
204
+ const payload = command.body || command.params;
205
+ this._startStep(stepName);
206
+ if (!(0, utils_1.isEmpty)(payload)) {
207
+ this.attachJSON('Request', payload);
208
+ }
209
+ }
210
+ onAfterCommand(command) {
211
+ const { disableWebdriverStepsReporting, disableWebdriverScreenshotsReporting } = this._options;
212
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
213
+ const commandResult = command.result || undefined;
214
+ const isScreenshot = (0, utils_1.isScreenshotCommand)(command);
215
+ if (!disableWebdriverScreenshotsReporting && isScreenshot && commandResult) {
216
+ this.attachFile('Screenshot', Buffer.from(commandResult, 'base64'), 'image/png');
217
+ }
218
+ if (disableWebdriverStepsReporting || this._isMultiremote || !this.storage.getCurrentStep()) {
219
+ return;
220
+ }
221
+ this.attachJSON('Response', commandResult);
222
+ this._endStep();
223
+ }
224
+ registerListeners() {
225
+ process.on(events_1.events.addQaseID, this.addQaseId.bind(this));
226
+ process.on(events_1.events.addTitle, this.addTitle.bind(this));
227
+ process.on(events_1.events.addFields, this.addFields.bind(this));
228
+ process.on(events_1.events.addSuite, this.addSuite.bind(this));
229
+ process.on(events_1.events.addParameters, this.addParameters.bind(this));
230
+ process.on(events_1.events.addAttachment, this.addAttachment.bind(this));
231
+ process.on(events_1.events.addIgnore, this.ignore.bind(this));
232
+ process.on(events_1.events.addStep, this.addStep.bind(this));
233
+ }
234
+ addQaseId({ ids }) {
235
+ const curTest = this.storage.getCurrentTest();
236
+ if (!curTest) {
237
+ return;
238
+ }
239
+ curTest.testops_id = ids;
240
+ }
241
+ addTitle({ title }) {
242
+ const curTest = this.storage.getCurrentTest();
243
+ if (!curTest) {
244
+ return;
245
+ }
246
+ curTest.title = title;
247
+ }
248
+ addSuite({ suite }) {
249
+ const curTest = this.storage.getCurrentTest();
250
+ if (!curTest) {
251
+ return;
252
+ }
253
+ curTest.relations = {
254
+ suite: {
255
+ data: [
256
+ {
257
+ title: suite,
258
+ public_id: null,
259
+ },
260
+ ],
261
+ },
262
+ };
263
+ }
264
+ addParameters({ records }) {
265
+ const curTest = this.storage.getCurrentTest();
266
+ if (!curTest) {
267
+ return;
268
+ }
269
+ const stringRecord = {};
270
+ for (const [key, value] of Object.entries(records)) {
271
+ stringRecord[String(key)] = String(value);
272
+ }
273
+ curTest.params = stringRecord;
274
+ }
275
+ addFields({ records }) {
276
+ const curTest = this.storage.getCurrentTest();
277
+ if (!curTest) {
278
+ return;
279
+ }
280
+ const stringRecord = {};
281
+ for (const [key, value] of Object.entries(records)) {
282
+ stringRecord[String(key)] = String(value);
283
+ }
284
+ curTest.fields = records;
285
+ }
286
+ addAttachment({ name, type, content, paths }) {
287
+ console.log('addAttachment');
288
+ console.log(name, type, content, paths);
289
+ const curTest = this.storage.getCurrentTest();
290
+ if (!curTest) {
291
+ return;
292
+ }
293
+ if (paths) {
294
+ for (const file of paths) {
295
+ const attachmentName = path_1.default.basename(file);
296
+ const contentType = (0, qase_javascript_commons_1.getMimeTypes)(file);
297
+ const attach = {
298
+ file_path: file,
299
+ size: 0,
300
+ id: (0, uuid_1.v4)(),
301
+ file_name: attachmentName,
302
+ mime_type: contentType,
303
+ content: '',
304
+ };
305
+ curTest.attachments.push(attach);
306
+ }
307
+ return;
308
+ }
309
+ if (content) {
310
+ const attachmentName = name ?? 'attachment';
311
+ const contentType = type ?? 'application/octet-stream';
312
+ const attach = {
313
+ file_path: null,
314
+ size: content.length,
315
+ id: (0, uuid_1.v4)(),
316
+ file_name: attachmentName,
317
+ mime_type: contentType,
318
+ content: content,
319
+ };
320
+ curTest.attachments.push(attach);
321
+ }
322
+ }
323
+ ignore() {
324
+ const curTest = this.storage.getCurrentTest();
325
+ if (!curTest) {
326
+ return;
327
+ }
328
+ this.storage.ignore = true;
329
+ }
330
+ addStep(step) {
331
+ const curItem = this.storage.getLastItem();
332
+ if (!curItem) {
333
+ return;
334
+ }
335
+ curItem.steps.push(step);
336
+ }
337
+ _startTest(title, cid, start_time = Date.now().valueOf() / 1000) {
338
+ const result = new qase_javascript_commons_1.TestResultType(title);
339
+ result.execution.thread = cid;
340
+ result.execution.start_time = start_time;
341
+ result.id = (0, uuid_1.v4)();
342
+ this.storage.push(result);
343
+ }
344
+ _startStep(title) {
345
+ const step = {
346
+ id: (0, uuid_1.v4)(),
347
+ step_type: qase_javascript_commons_1.StepType.TEXT,
348
+ data: {
349
+ action: title,
350
+ expected_result: null,
351
+ },
352
+ parent_id: this.storage.getLastItem()?.id ?? null,
353
+ execution: {
354
+ start_time: Date.now().valueOf() / 1000,
355
+ end_time: null,
356
+ status: qase_javascript_commons_1.StepStatusEnum.passed,
357
+ duration: null,
358
+ },
359
+ steps: [],
360
+ attachments: [],
361
+ };
362
+ this.storage.getLastItem()?.steps.push(step);
363
+ this.storage.push(step);
364
+ }
365
+ attachJSON(name, json) {
366
+ const isStr = typeof json === 'string';
367
+ const content = isStr ? json : JSON.stringify(json, null, 2);
368
+ this.attachFile(name, String(content), isStr ? 'application/json' : 'text/plain');
369
+ }
370
+ attachFile(name, content, contentType) {
371
+ if (!this.storage.getLastItem()) {
372
+ throw new Error('There isn\'t any active test!');
373
+ }
374
+ const attach = {
375
+ file_path: null,
376
+ size: content.length,
377
+ id: (0, uuid_1.v4)(),
378
+ file_name: name,
379
+ mime_type: contentType,
380
+ content: content,
381
+ };
382
+ console.log('attachFile:', attach);
383
+ this.storage.getLastItem()?.attachments.push(attach);
384
+ }
385
+ _endStep(status = qase_javascript_commons_1.TestStatusEnum.passed) {
386
+ if (!this.storage.getLastItem()) {
387
+ return;
388
+ }
389
+ const step = this.storage.pop();
390
+ if (!step) {
391
+ return;
392
+ }
393
+ step.execution.end_time = Date.now().valueOf() / 1000;
394
+ step.execution.status = status;
395
+ }
396
+ parseTag(tag) {
397
+ const [key, value] = tag.split('=');
398
+ if (!key || !value) {
399
+ return null;
400
+ }
401
+ return { key, value };
402
+ }
403
+ }
404
+ /**
405
+ * @type {Record<string, TestStatusEnum>}
406
+ */
407
+ WDIOQaseReporter.statusMap = {
408
+ 'passed': qase_javascript_commons_1.TestStatusEnum.passed,
409
+ 'failed': qase_javascript_commons_1.TestStatusEnum.failed,
410
+ 'skipped': qase_javascript_commons_1.TestStatusEnum.skipped,
411
+ 'pending': qase_javascript_commons_1.TestStatusEnum.skipped,
412
+ };
413
+ exports.default = WDIOQaseReporter;
package/dist/step.d.ts ADDED
@@ -0,0 +1,16 @@
1
+ import { Attachment, TestStepType } from 'qase-javascript-commons';
2
+ export type StepFunction<T = any> = (this: QaseStep, step: QaseStep) => T | Promise<T>;
3
+ export declare class QaseStep {
4
+ name: string;
5
+ attachments: Attachment[];
6
+ steps: TestStepType[];
7
+ constructor(name: string);
8
+ attach(attach: {
9
+ name?: string;
10
+ type?: string;
11
+ content?: string;
12
+ paths?: string[] | string;
13
+ }): void;
14
+ step(name: string, body: StepFunction): Promise<void>;
15
+ run(body: StepFunction, messageEmitter: (step: TestStepType) => Promise<void>): Promise<void>;
16
+ }
package/dist/step.js ADDED
@@ -0,0 +1,87 @@
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
+ exports.QaseStep = void 0;
7
+ const qase_javascript_commons_1 = require("qase-javascript-commons");
8
+ const uuid_1 = require("uuid");
9
+ const path_1 = __importDefault(require("path"));
10
+ class QaseStep {
11
+ constructor(name) {
12
+ this.name = '';
13
+ this.attachments = [];
14
+ this.steps = [];
15
+ this.name = name;
16
+ }
17
+ attach(attach) {
18
+ if (attach.paths) {
19
+ const files = Array.isArray(attach.paths) ? attach.paths : [attach.paths];
20
+ for (const file of files) {
21
+ const attachmentName = path_1.default.basename(file);
22
+ const contentType = 'application/octet-stream';
23
+ this.attachments.push({
24
+ id: (0, uuid_1.v4)(),
25
+ file_name: attachmentName,
26
+ mime_type: contentType,
27
+ content: '',
28
+ file_path: file,
29
+ size: 0,
30
+ });
31
+ }
32
+ return;
33
+ }
34
+ if (attach.content) {
35
+ const attachmentName = attach.name ?? 'attachment';
36
+ const contentType = attach.type ?? 'application/octet-stream';
37
+ this.attachments.push({
38
+ id: (0, uuid_1.v4)(),
39
+ file_name: attachmentName,
40
+ mime_type: contentType,
41
+ content: attach.content,
42
+ file_path: null,
43
+ size: attach.content.length,
44
+ });
45
+ }
46
+ }
47
+ async step(name, body) {
48
+ const childStep = new QaseStep(name);
49
+ // eslint-disable-next-line @typescript-eslint/require-await
50
+ await childStep.run(body, async (step) => {
51
+ this.steps.push(step);
52
+ });
53
+ }
54
+ async run(body, messageEmitter) {
55
+ const startDate = new Date().getTime();
56
+ const step = new qase_javascript_commons_1.TestStepType();
57
+ step.data = {
58
+ action: this.name,
59
+ expected_result: null,
60
+ };
61
+ try {
62
+ await body.call(this, this);
63
+ step.execution = {
64
+ start_time: startDate,
65
+ end_time: new Date().getTime(),
66
+ status: qase_javascript_commons_1.StepStatusEnum.passed,
67
+ duration: null,
68
+ };
69
+ step.attachments = this.attachments;
70
+ step.steps = this.steps;
71
+ await messageEmitter(step);
72
+ }
73
+ catch (e) {
74
+ step.execution = {
75
+ start_time: startDate,
76
+ end_time: new Date().getTime(),
77
+ status: qase_javascript_commons_1.StepStatusEnum.failed,
78
+ duration: null,
79
+ };
80
+ step.attachments = this.attachments;
81
+ step.steps = this.steps;
82
+ await messageEmitter(step);
83
+ throw e;
84
+ }
85
+ }
86
+ }
87
+ exports.QaseStep = QaseStep;
@@ -0,0 +1,14 @@
1
+ import { TestResultType, TestStepType } from 'qase-javascript-commons';
2
+ export declare class Storage {
3
+ currentFile?: string | undefined;
4
+ suites: string[];
5
+ ignore: boolean;
6
+ items: (TestResultType | TestStepType)[];
7
+ clear(): void;
8
+ push(item: TestResultType | TestStepType): void;
9
+ pop(): TestResultType | TestStepType | undefined;
10
+ getCurrentTest(): TestResultType | undefined;
11
+ getCurrentStep(): TestStepType | undefined;
12
+ getLastItem(): TestResultType | TestStepType | undefined;
13
+ }
14
+ export declare const findLast: <T>(arr: T[], predicate: (el: T) => boolean) => T | undefined;
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.findLast = exports.Storage = void 0;
4
+ const qase_javascript_commons_1 = require("qase-javascript-commons");
5
+ class Storage {
6
+ constructor() {
7
+ this.suites = [];
8
+ this.ignore = false;
9
+ this.items = [];
10
+ }
11
+ clear() {
12
+ this.currentFile = undefined;
13
+ this.suites = [];
14
+ this.items = [];
15
+ this.ignore = false;
16
+ }
17
+ push(item) {
18
+ this.items.push(item);
19
+ }
20
+ pop() {
21
+ return this.items.pop();
22
+ }
23
+ getCurrentTest() {
24
+ return (0, exports.findLast)(this.items, (item) => item instanceof qase_javascript_commons_1.TestResultType);
25
+ }
26
+ getCurrentStep() {
27
+ return (0, exports.findLast)(this.items, (item) => item instanceof qase_javascript_commons_1.TestStepType);
28
+ }
29
+ getLastItem() {
30
+ return this.items[this.items.length - 1];
31
+ }
32
+ }
33
+ exports.Storage = Storage;
34
+ const findLast = (arr, predicate) => {
35
+ let result;
36
+ for (let i = arr.length - 1; i >= 0; i--) {
37
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
38
+ // @ts-ignore
39
+ if (predicate(arr[i])) {
40
+ result = arr[i];
41
+ break;
42
+ }
43
+ }
44
+ return result;
45
+ };
46
+ exports.findLast = findLast;
@@ -0,0 +1,8 @@
1
+ import { CommandArgs } from '@wdio/reporter';
2
+ /**
3
+ * Check is object is empty
4
+ * @param object {Object}
5
+ * @private
6
+ */
7
+ export declare const isEmpty: (object: any) => boolean;
8
+ export declare const isScreenshotCommand: (command: CommandArgs) => boolean;
package/dist/utils.js ADDED
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isScreenshotCommand = exports.isEmpty = void 0;
4
+ /**
5
+ * Check is object is empty
6
+ * @param object {Object}
7
+ * @private
8
+ */
9
+ const isEmpty = (object) =>
10
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
11
+ !object || Object.keys(object).length === 0;
12
+ exports.isEmpty = isEmpty;
13
+ const isScreenshotCommand = (command) => {
14
+ const isScreenshotEndpoint = /\/session\/[^/]*(\/element\/[^/]*)?\/screenshot/;
15
+ return (
16
+ // WebDriver protocol
17
+ (command.endpoint && isScreenshotEndpoint.test(command.endpoint)) ||
18
+ // DevTools protocol
19
+ command.command === 'takeScreenshot');
20
+ };
21
+ exports.isScreenshotCommand = isScreenshotCommand;
package/dist/wdio.d.ts ADDED
@@ -0,0 +1,55 @@
1
+ import { StepFunction } from './step';
2
+ export declare class qase {
3
+ /**
4
+ * Assign QaseID to test
5
+ * @name id
6
+ * @param {number | number[]} value
7
+ */
8
+ static id(value: number | number[]): typeof qase;
9
+ /**
10
+ * Assign title to test
11
+ * @name title
12
+ * @param {string} value
13
+ */
14
+ static title(value: string): typeof qase;
15
+ /**
16
+ * Assign parameters to test
17
+ * @name parameters
18
+ * @param {Record<string, string>} values
19
+ */
20
+ static parameters(values: Record<string, string>): typeof qase;
21
+ /**
22
+ * Assign fields to test
23
+ * @name fields
24
+ * @param {Record<string, string>} values
25
+ */
26
+ static fields(values: Record<string, string>): typeof qase;
27
+ /**
28
+ * Assign suite to test
29
+ * @name suite
30
+ * @param {string} value
31
+ */
32
+ static suite(value: string): typeof qase;
33
+ /**
34
+ * Assign ignore mark to test
35
+ * @name ignore
36
+ */
37
+ static ignore(): typeof qase;
38
+ /**
39
+ * Assign attachment to test
40
+ * @name attach
41
+ * @param attach
42
+ */
43
+ static attach(attach: {
44
+ name?: string;
45
+ type?: string;
46
+ content?: string;
47
+ paths?: string[];
48
+ }): typeof qase;
49
+ /**
50
+ * Starts step
51
+ * @param {string} name - the step name
52
+ * @param {StepFunction} body - the step content function
53
+ */
54
+ static step(name: string, body: StepFunction): Promise<void>;
55
+ }
package/dist/wdio.js ADDED
@@ -0,0 +1,90 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.qase = void 0;
4
+ const events_1 = require("./events");
5
+ const step_1 = require("./step");
6
+ /**
7
+ * Send event to reporter
8
+ * @param {string} event - event name
9
+ * @param {object} msg - event payload
10
+ * @private
11
+ */
12
+ const sendEvent = (event, msg = {}) => {
13
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
14
+ process.emit(event, msg);
15
+ };
16
+ class qase {
17
+ /**
18
+ * Assign QaseID to test
19
+ * @name id
20
+ * @param {number | number[]} value
21
+ */
22
+ static id(value) {
23
+ sendEvent(events_1.events.addQaseID, { ids: Array.isArray(value) ? value : [value] });
24
+ return this;
25
+ }
26
+ /**
27
+ * Assign title to test
28
+ * @name title
29
+ * @param {string} value
30
+ */
31
+ static title(value) {
32
+ sendEvent(events_1.events.addTitle, { title: value });
33
+ return this;
34
+ }
35
+ /**
36
+ * Assign parameters to test
37
+ * @name parameters
38
+ * @param {Record<string, string>} values
39
+ */
40
+ static parameters(values) {
41
+ sendEvent(events_1.events.addParameters, { records: values });
42
+ return this;
43
+ }
44
+ /**
45
+ * Assign fields to test
46
+ * @name fields
47
+ * @param {Record<string, string>} values
48
+ */
49
+ static fields(values) {
50
+ sendEvent(events_1.events.addFields, { records: values });
51
+ return this;
52
+ }
53
+ /**
54
+ * Assign suite to test
55
+ * @name suite
56
+ * @param {string} value
57
+ */
58
+ static suite(value) {
59
+ sendEvent(events_1.events.addSuite, { suite: value });
60
+ return this;
61
+ }
62
+ /**
63
+ * Assign ignore mark to test
64
+ * @name ignore
65
+ */
66
+ static ignore() {
67
+ sendEvent(events_1.events.addIgnore, {});
68
+ return this;
69
+ }
70
+ /**
71
+ * Assign attachment to test
72
+ * @name attach
73
+ * @param attach
74
+ */
75
+ static attach(attach) {
76
+ sendEvent(events_1.events.addAttachment, attach);
77
+ return this;
78
+ }
79
+ /**
80
+ * Starts step
81
+ * @param {string} name - the step name
82
+ * @param {StepFunction} body - the step content function
83
+ */
84
+ static async step(name, body) {
85
+ const runningStep = new step_1.QaseStep(name);
86
+ // eslint-disable-next-line @typescript-eslint/require-await
87
+ await runningStep.run(body, async (message) => sendEvent(events_1.events.addStep, message));
88
+ }
89
+ }
90
+ exports.qase = qase;
package/package.json ADDED
@@ -0,0 +1,43 @@
1
+ {
2
+ "name": "wdio-qase-reporter",
3
+ "version": "1.0.0-beta.1",
4
+ "description": "Qase WebDriverIO Reporter",
5
+ "homepage": "https://github.com/qase-tms/qase-javascript",
6
+ "sideEffects": false,
7
+ "main": "./dist/index.js",
8
+ "bugs": {
9
+ "url": "https://github.com/qase-tms/qase-javascript/issues"
10
+ },
11
+ "keywords": [
12
+ "reporter",
13
+ "webdriverio",
14
+ "wdio",
15
+ "wdio-plugin",
16
+ "wdio-reporter",
17
+ "qase"
18
+ ],
19
+ "repository": {
20
+ "type": "git",
21
+ "url": "git+https://github.com/qase-tms/qase-javascript.git"
22
+ },
23
+ "engines": {
24
+ "node": ">=14"
25
+ },
26
+ "scripts": {
27
+ "build": "npm run clean && tsc --project tsconfig.build.json",
28
+ "lint": "eslint .",
29
+ "test": "jest --passWithNoTests",
30
+ "clean": "rm -rf dist"
31
+ },
32
+ "author": "Qase Team <support@qase.io>",
33
+ "license": "Apache-2.0",
34
+ "dependencies": {
35
+ "qase-javascript-commons": "~2.1.2",
36
+ "uuid": "^9.0.1",
37
+ "@types/node": "^20.1.0",
38
+ "@wdio/reporter": "^8.39.0",
39
+ "@wdio/types": "^8.39.0",
40
+ "csv-stringify": "^6.0.4",
41
+ "strip-ansi": "^7.1.0"
42
+ }
43
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ "extends": "./tsconfig.json",
3
+
4
+ "compilerOptions": {
5
+ "noEmit": false
6
+ },
7
+
8
+ "include": ["./src/**/*.ts"]
9
+ }