@wdio/allure-reporter 7.20.7 → 7.20.8-alpha.504

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
@@ -1,7 +1,7 @@
1
1
  WDIO Allure Reporter
2
2
  ====================
3
3
 
4
- > A WebdriverIO reporter plugin to create [Allure Test Reports](https://docs.qameta.io/allure/).
4
+ > A WebdriverIO reporter plugin to create [Allure Test Reports](https://docs.qameta.io/allure-report/).
5
5
 
6
6
  ![Allure Reporter Example](/img/allure.png)
7
7
 
@@ -76,13 +76,13 @@ exports.config = {
76
76
  ### Usage
77
77
  Allure Api can be accessed using:
78
78
 
79
- ES5
79
+ CJS
80
80
 
81
81
  ```js
82
82
  const allureReporter = require('@wdio/allure-reporter').default
83
83
  ```
84
84
 
85
- ES6
85
+ ESM
86
86
 
87
87
  ```js
88
88
  import allureReporter from '@wdio/allure-reporter'
@@ -1,5 +1,3 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
1
  function indentAll(lines) {
4
2
  return lines.split('\n').map(x => ' ' + x).join('\n');
5
3
  }
@@ -7,7 +5,8 @@ function indentAll(lines) {
7
5
  * An error that encapsulates more than one error, to support soft-assertions from Jasmine
8
6
  * even though Allure's API assumes one error-per test
9
7
  */
10
- class CompoundError extends Error {
8
+ export default class CompoundError extends Error {
9
+ innerErrors;
11
10
  constructor(...innerErrors) {
12
11
  const message = ['CompoundError: One or more errors occurred. ---\n'].
13
12
  concat(innerErrors.map(x => {
@@ -19,4 +18,3 @@ class CompoundError extends Error {
19
18
  this.innerErrors = innerErrors;
20
19
  }
21
20
  }
22
- exports.default = CompoundError;
@@ -1,27 +1,22 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.linkPlaceholder = exports.mochaAllHooks = exports.mochaEachHooks = exports.events = exports.stepStatuses = exports.testStatuses = exports.SKIPPED = exports.CANCELED = exports.PENDING = exports.BROKEN = exports.FAILED = exports.PASSED = void 0;
4
- exports.PASSED = 'passed';
5
- exports.FAILED = 'failed';
6
- exports.BROKEN = 'broken';
7
- exports.PENDING = 'pending';
8
- exports.CANCELED = 'canceled';
9
- exports.SKIPPED = 'skipped';
1
+ export const PASSED = 'passed';
2
+ export const FAILED = 'failed';
3
+ export const BROKEN = 'broken';
4
+ export const PENDING = 'pending';
5
+ export const CANCELED = 'canceled';
6
+ export const SKIPPED = 'skipped';
10
7
  const testStatuses = {
11
- PASSED: exports.PASSED,
12
- FAILED: exports.FAILED,
13
- BROKEN: exports.BROKEN,
14
- PENDING: exports.PENDING
8
+ PASSED,
9
+ FAILED,
10
+ BROKEN,
11
+ PENDING
15
12
  };
16
- exports.testStatuses = testStatuses;
17
13
  const stepStatuses = {
18
- PASSED: exports.PASSED,
19
- FAILED: exports.FAILED,
20
- BROKEN: exports.BROKEN,
21
- CANCELED: exports.CANCELED,
22
- SKIPPED: exports.SKIPPED
14
+ PASSED,
15
+ FAILED,
16
+ BROKEN,
17
+ CANCELED,
18
+ SKIPPED
23
19
  };
24
- exports.stepStatuses = stepStatuses;
25
20
  const events = {
26
21
  addLabel: 'allure:addLabel',
27
22
  addFeature: 'allure:addFeature',
@@ -37,10 +32,7 @@ const events = {
37
32
  addStep: 'allure:addStep',
38
33
  addArgument: 'allure:addArgument'
39
34
  };
40
- exports.events = events;
41
35
  const mochaEachHooks = ['"before each" hook', '"after each" hook'];
42
- exports.mochaEachHooks = mochaEachHooks;
43
36
  const mochaAllHooks = ['"before all" hook', '"after all" hook'];
44
- exports.mochaAllHooks = mochaAllHooks;
45
37
  const linkPlaceholder = '{}';
46
- exports.linkPlaceholder = linkPlaceholder;
38
+ export { testStatuses, stepStatuses, events, mochaEachHooks, mochaAllHooks, linkPlaceholder };
package/build/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  /// <reference types="node" />
2
2
  import WDIOReporter, { SuiteStats, HookStats, RunnerStats, TestStats, BeforeCommandArgs, AfterCommandArgs, CommandArgs } from '@wdio/reporter';
3
- import { AddAttachmentEventArgs, AddDescriptionEventArgs, AddEnvironmentEventArgs, AddFeatureEventArgs, AddIssueEventArgs, AddLabelEventArgs, AddSeverityEventArgs, AddStoryEventArgs, AddTestIdEventArgs, AllureReporterOptions, Status } from './types';
3
+ import { AddAttachmentEventArgs, AddDescriptionEventArgs, AddEnvironmentEventArgs, AddFeatureEventArgs, AddIssueEventArgs, AddLabelEventArgs, AddSeverityEventArgs, AddStoryEventArgs, AddTestIdEventArgs, AllureReporterOptions, Status } from './types.js';
4
4
  declare class AllureReporter extends WDIOReporter {
5
5
  private _allure;
6
6
  private _capabilities;
@@ -11,13 +11,15 @@ declare class AllureReporter extends WDIOReporter {
11
11
  private _consoleOutput;
12
12
  private _originalStdoutWrite;
13
13
  private _addConsoleLogs;
14
+ private _startedFeatures;
14
15
  constructor(options?: AllureReporterOptions);
15
16
  registerListeners(): void;
16
17
  onRunnerStart(runner: RunnerStats): void;
17
- onSuiteStart(suite: SuiteStats): any;
18
+ onSuiteStart(suite: SuiteStats): void;
18
19
  onSuiteEnd(suite: SuiteStats): any;
19
- onTestStart(test: TestStats | HookStats): any;
20
- setCaseParameters(cid: string | undefined): void;
20
+ onTestStart(test: TestStats | HookStats): void;
21
+ setCaseParameters(cid: string | undefined, parentUid: string | undefined): void;
22
+ getParentSuite(uid?: string): SuiteStats | undefined;
21
23
  getLabels({ tags }: SuiteStats): {
22
24
  name: string;
23
25
  value: string;
@@ -138,7 +140,7 @@ declare class AllureReporter extends WDIOReporter {
138
140
  }
139
141
  export default AllureReporter;
140
142
  export { AllureReporterOptions };
141
- export * from './types';
143
+ export * from './types.js';
142
144
  declare global {
143
145
  namespace WebdriverIO {
144
146
  interface ReporterOption extends AllureReporterOptions {
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,OAAO,YAAY,EAAE,EACjB,UAAU,EAAO,SAAS,EAAE,WAAW,EAAE,SAA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,GAAG,WAAe,MAAM,UAO1B;IAED;;;;;OAKG;IACH,MAAM,CAAC,WAAW,SAAU,MAAM,SAAS,MAAM,UAEhD;CACJ;AAED,eAAe,cAAc,CAAA;AAE7B,OAAO,EAAE,qBAAqB,EAAE,CAAA;AAChC,cAAc,YAAY,CAAA;AAE1B,OAAO,CAAC,MAAM,CAAC;IACX,UAAU,WAAW,CAAC;QAClB,UAAU,cAAe,SAAQ,qBAAqB;SAAI;KAC7D;CACJ"}
package/build/index.js CHANGED
@@ -1,33 +1,26 @@
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_1 = __importDefault(require("@wdio/reporter"));
21
- const utils_1 = require("./utils");
22
- const constants_1 = require("./constants");
23
- const sync_1 = require("csv-stringify/sync");
1
+ import { createRequire } from 'node:module';
2
+ import { stringify } from 'csv-stringify/sync';
3
+ import WDIOReporter from '@wdio/reporter';
4
+ import { getTestStatus, isEmpty, tellReporter, isMochaEachHooks, getErrorFromFailedTest, isMochaAllHooks, getLinkByTemplate, attachConsoleLogs } from './utils.js';
5
+ import { events, PASSED, PENDING, SKIPPED, stepStatuses } from './constants.js';
6
+ const require = createRequire(import.meta.url);
24
7
  /**
25
8
  * Allure v1 has no proper TS support
26
9
  * ToDo(Christian): update to Allure v2 (https://github.com/webdriverio/webdriverio/issues/6313)
27
10
  */
28
11
  const Allure = require('allure-js-commons');
29
- const Step = require('allure-js-commons/beans/step');
30
- class AllureReporter extends reporter_1.default {
12
+ const Step = require('allure-js-commons/beans/step.js');
13
+ class AllureReporter extends WDIOReporter {
14
+ _allure;
15
+ _capabilities;
16
+ _isMultiremote;
17
+ _config;
18
+ _lastScreenshot;
19
+ _options;
20
+ _consoleOutput;
21
+ _originalStdoutWrite;
22
+ _addConsoleLogs;
23
+ _startedFeatures = [];
31
24
  constructor(options = {}) {
32
25
  const outputDir = options.outputDir || 'allure-results';
33
26
  super({
@@ -54,19 +47,19 @@ class AllureReporter extends reporter_1.default {
54
47
  }
55
48
  }
56
49
  registerListeners() {
57
- process.on(constants_1.events.addLabel, this.addLabel.bind(this));
58
- process.on(constants_1.events.addFeature, this.addFeature.bind(this));
59
- process.on(constants_1.events.addStory, this.addStory.bind(this));
60
- process.on(constants_1.events.addSeverity, this.addSeverity.bind(this));
61
- process.on(constants_1.events.addIssue, this.addIssue.bind(this));
62
- process.on(constants_1.events.addTestId, this.addTestId.bind(this));
63
- process.on(constants_1.events.addEnvironment, this.addEnvironment.bind(this));
64
- process.on(constants_1.events.addAttachment, this.addAttachment.bind(this));
65
- process.on(constants_1.events.addDescription, this.addDescription.bind(this));
66
- process.on(constants_1.events.startStep, this.startStep.bind(this));
67
- process.on(constants_1.events.endStep, this.endStep.bind(this));
68
- process.on(constants_1.events.addStep, this.addStep.bind(this));
69
- process.on(constants_1.events.addArgument, this.addArgument.bind(this));
50
+ process.on(events.addLabel, this.addLabel.bind(this));
51
+ process.on(events.addFeature, this.addFeature.bind(this));
52
+ process.on(events.addStory, this.addStory.bind(this));
53
+ process.on(events.addSeverity, this.addSeverity.bind(this));
54
+ process.on(events.addIssue, this.addIssue.bind(this));
55
+ process.on(events.addTestId, this.addTestId.bind(this));
56
+ process.on(events.addEnvironment, this.addEnvironment.bind(this));
57
+ process.on(events.addAttachment, this.addAttachment.bind(this));
58
+ process.on(events.addDescription, this.addDescription.bind(this));
59
+ process.on(events.startStep, this.startStep.bind(this));
60
+ process.on(events.endStep, this.endStep.bind(this));
61
+ process.on(events.addStep, this.addStep.bind(this));
62
+ process.on(events.addArgument, this.addArgument.bind(this));
70
63
  }
71
64
  onRunnerStart(runner) {
72
65
  this._config = runner.config;
@@ -74,27 +67,36 @@ class AllureReporter extends reporter_1.default {
74
67
  this._isMultiremote = runner.isMultiremote || false;
75
68
  }
76
69
  onSuiteStart(suite) {
77
- if (this._options.useCucumberStepReporter) {
78
- if (suite.type === 'feature') {
79
- // handle cucumber features as allure "suite"
80
- return this._allure.startSuite(suite.title);
81
- }
82
- // handle cucumber scenario as allure "case" instead of "suite"
83
- this._allure.startCase(suite.title);
84
- const currentTest = this._allure.getCurrentTest();
85
- this.getLabels(suite).forEach(({ name, value }) => {
86
- currentTest.addLabel(name, value);
87
- });
88
- if (suite.description) {
89
- this.addDescription(suite);
90
- }
91
- return this.setCaseParameters(suite.cid);
70
+ const isFeature = suite.type === 'feature';
71
+ if (!this._options.useCucumberStepReporter) {
72
+ const currentSuite = this._allure.getCurrentSuite();
73
+ const prefix = currentSuite ? currentSuite.name + ': ' : '';
74
+ this._allure.startSuite(prefix + suite.title);
75
+ return;
92
76
  }
93
- const currentSuite = this._allure.getCurrentSuite();
94
- const prefix = currentSuite ? currentSuite.name + ': ' : '';
95
- this._allure.startSuite(prefix + suite.title);
77
+ // handle cucumber features as allure "suite"
78
+ if (isFeature) {
79
+ // temp solution to keep suites stats index for saving allure test ops feature based structure
80
+ this._startedFeatures.push(suite);
81
+ this._allure.startSuite(suite.title);
82
+ return;
83
+ }
84
+ // handle cucumber scenario as allure "case" instead of "suite"
85
+ this._allure.startCase(suite.title);
86
+ const currentTest = this._allure.getCurrentTest();
87
+ this.getLabels(suite).forEach(({ name, value }) => {
88
+ currentTest.addLabel(name, value);
89
+ });
90
+ if (suite.description) {
91
+ this.addDescription(suite);
92
+ }
93
+ this.setCaseParameters(suite.cid, suite.parent);
96
94
  }
97
95
  onSuiteEnd(suite) {
96
+ // cleanup suites index to prevent resource leaks
97
+ if (suite.type === 'feature') {
98
+ this._startedFeatures = this._startedFeatures.filter((suite) => suite.uid !== suite.uid);
99
+ }
98
100
  if (this._options.useCucumberStepReporter && suite.type === 'scenario') {
99
101
  // passing hooks are missing the 'state' property
100
102
  suite.hooks = suite.hooks.map((hook) => {
@@ -107,12 +109,12 @@ class AllureReporter extends reporter_1.default {
107
109
  return this._allure.endCase('passed');
108
110
  }
109
111
  // A scenario is it skipped if every steps are skipped and hooks are passed or skipped
110
- const isSkipped = suite.tests.every(item => [constants_1.SKIPPED].indexOf(item.state) >= 0) && suite.hooks.every(item => [constants_1.PASSED, constants_1.SKIPPED].indexOf(item.state) >= 0);
112
+ const isSkipped = suite.tests.every(item => [SKIPPED].indexOf(item.state) >= 0) && suite.hooks.every(item => [PASSED, SKIPPED].indexOf(item.state) >= 0);
111
113
  if (isSkipped) {
112
- return this._allure.endCase(constants_1.PENDING);
114
+ return this._allure.endCase(PENDING);
113
115
  }
114
116
  // A scenario is it passed if certain steps are passed and all other are skipped and every hooks are passed or skipped
115
- const isPartiallySkipped = suiteChildren.every(item => [constants_1.PASSED, constants_1.SKIPPED].indexOf(item.state) >= 0);
117
+ const isPartiallySkipped = suiteChildren.every(item => [PASSED, SKIPPED].indexOf(item.state) >= 0);
116
118
  if (isPartiallySkipped) {
117
119
  return this._allure.endCase('passed');
118
120
  }
@@ -123,28 +125,28 @@ class AllureReporter extends reporter_1.default {
123
125
  this._allure.endSuite();
124
126
  }
125
127
  onTestStart(test) {
126
- var _a;
127
128
  this._consoleOutput = '';
128
129
  const testTitle = test.currentTest ? test.currentTest : test.title;
129
130
  if (this.isAnyTestRunning() && this._allure.getCurrentTest().name == testTitle) {
130
131
  // Test already in progress, most likely started by a before each hook
131
- this.setCaseParameters(test.cid);
132
+ this.setCaseParameters(test.cid, test.parent);
132
133
  return;
133
134
  }
134
135
  if (this._options.useCucumberStepReporter) {
135
- const step = this._allure.startStep(testTitle);
136
+ this._allure.startStep(testTitle);
136
137
  const testObj = test;
137
- const argument = testObj === null || testObj === void 0 ? void 0 : testObj.argument;
138
- const dataTable = (_a = argument === null || argument === void 0 ? void 0 : argument.rows) === null || _a === void 0 ? void 0 : _a.map((a) => a === null || a === void 0 ? void 0 : a.cells);
138
+ const argument = testObj?.argument;
139
+ const dataTable = argument?.rows?.map((a) => a?.cells);
139
140
  if (dataTable) {
140
- this._allure.addAttachment('Data Table', (0, sync_1.stringify)(dataTable), 'text/csv');
141
+ this._allure.addAttachment('Data Table', stringify(dataTable), 'text/csv');
141
142
  }
142
- return step;
143
+ return;
143
144
  }
144
145
  this._allure.startCase(testTitle);
145
- this.setCaseParameters(test.cid);
146
+ this.setCaseParameters(test.cid, test.parent);
146
147
  }
147
- setCaseParameters(cid) {
148
+ setCaseParameters(cid, parentUid) {
149
+ const parentSuite = this.getParentSuite(parentUid);
148
150
  const currentTest = this._allure.getCurrentTest();
149
151
  if (!this._isMultiremote) {
150
152
  const caps = this._capabilities;
@@ -167,6 +169,15 @@ class AllureReporter extends reporter_1.default {
167
169
  currentTest.addLabel('language', 'javascript');
168
170
  currentTest.addLabel('framework', 'wdio');
169
171
  currentTest.addLabel('thread', cid);
172
+ if (parentSuite?.title) {
173
+ currentTest.addLabel('feature', parentSuite?.title);
174
+ }
175
+ }
176
+ getParentSuite(uid) {
177
+ if (!uid) {
178
+ return undefined;
179
+ }
180
+ return this._startedFeatures.find((suite) => suite.uid === uid);
170
181
  }
171
182
  getLabels({ tags }) {
172
183
  const labels = [];
@@ -181,26 +192,26 @@ class AllureReporter extends reporter_1.default {
181
192
  return labels;
182
193
  }
183
194
  onTestPass() {
184
- (0, utils_1.attachConsoleLogs)(this._consoleOutput, this._allure);
195
+ attachConsoleLogs(this._consoleOutput, this._allure);
185
196
  if (this._options.useCucumberStepReporter) {
186
197
  const suite = this._allure.getCurrentSuite();
187
198
  if (suite && suite.currentStep instanceof Step) {
188
199
  return this._allure.endStep('passed');
189
200
  }
190
201
  }
191
- this._allure.endCase(constants_1.PASSED);
202
+ this._allure.endCase(PASSED);
192
203
  }
193
204
  onTestFail(test) {
194
205
  if (this._options.useCucumberStepReporter) {
195
- (0, utils_1.attachConsoleLogs)(this._consoleOutput, this._allure);
196
- const testStatus = (0, utils_1.getTestStatus)(test, this._config);
197
- const stepStatus = Object.values(constants_1.stepStatuses).indexOf(testStatus) >= 0 ?
206
+ attachConsoleLogs(this._consoleOutput, this._allure);
207
+ const testStatus = getTestStatus(test, this._config);
208
+ const stepStatus = Object.values(stepStatuses).indexOf(testStatus) >= 0 ?
198
209
  testStatus : 'failed';
199
210
  const suite = this._allure.getCurrentSuite();
200
211
  if (suite && suite.currentStep instanceof Step) {
201
212
  this._allure.endStep(stepStatus);
202
213
  }
203
- this._allure.endCase(testStatus, (0, utils_1.getErrorFromFailedTest)(test));
214
+ this._allure.endCase(testStatus, getErrorFromFailedTest(test));
204
215
  return;
205
216
  }
206
217
  if (!this.isAnyTestRunning()) { // is any CASE running
@@ -209,15 +220,15 @@ class AllureReporter extends reporter_1.default {
209
220
  else {
210
221
  this._allure.getCurrentTest().name = test.title;
211
222
  }
212
- (0, utils_1.attachConsoleLogs)(this._consoleOutput, this._allure);
213
- const status = (0, utils_1.getTestStatus)(test, this._config);
223
+ attachConsoleLogs(this._consoleOutput, this._allure);
224
+ const status = getTestStatus(test, this._config);
214
225
  while (this._allure.getCurrentSuite().currentStep instanceof Step) {
215
226
  this._allure.endStep(status);
216
227
  }
217
- this._allure.endCase(status, (0, utils_1.getErrorFromFailedTest)(test));
228
+ this._allure.endCase(status, getErrorFromFailedTest(test));
218
229
  }
219
230
  onTestSkip(test) {
220
- (0, utils_1.attachConsoleLogs)(this._consoleOutput, this._allure);
231
+ attachConsoleLogs(this._consoleOutput, this._allure);
221
232
  if (this._options.useCucumberStepReporter) {
222
233
  const suite = this._allure.getCurrentSuite();
223
234
  if (suite && suite.currentStep instanceof Step) {
@@ -243,7 +254,7 @@ class AllureReporter extends reporter_1.default {
243
254
  ? `${command.method} ${command.endpoint}`
244
255
  : command.command);
245
256
  const payload = command.body || command.params;
246
- if (!(0, utils_1.isEmpty)(payload)) {
257
+ if (!isEmpty(payload)) {
247
258
  this.dumpJSON('Request', payload);
248
259
  }
249
260
  }
@@ -278,14 +289,14 @@ class AllureReporter extends reporter_1.default {
278
289
  return false;
279
290
  }
280
291
  // add beforeEach / afterEach hook as step to test
281
- if (this._options.disableMochaHooks && (0, utils_1.isMochaEachHooks)(hook.title)) {
292
+ if (this._options.disableMochaHooks && isMochaEachHooks(hook.title)) {
282
293
  if (this._allure.getCurrentTest()) {
283
294
  this._allure.startStep(hook.title);
284
295
  }
285
296
  return;
286
297
  }
287
298
  // don't add hook as test to suite for mocha All hooks
288
- if (this._options.disableMochaHooks && (0, utils_1.isMochaAllHooks)(hook.title)) {
299
+ if (this._options.disableMochaHooks && isMochaAllHooks(hook.title)) {
289
300
  return;
290
301
  }
291
302
  // add hook as test to suite
@@ -293,11 +304,11 @@ class AllureReporter extends reporter_1.default {
293
304
  }
294
305
  onHookEnd(hook) {
295
306
  // ignore global hooks
296
- if (!hook.parent || !this._allure.getCurrentSuite() || (this._options.disableMochaHooks && !(0, utils_1.isMochaAllHooks)(hook.title) && !this._allure.getCurrentTest())) {
307
+ if (!hook.parent || !this._allure.getCurrentSuite() || (this._options.disableMochaHooks && !isMochaAllHooks(hook.title) && !this._allure.getCurrentTest())) {
297
308
  return false;
298
309
  }
299
310
  // set beforeEach / afterEach hook (step) status
300
- if (this._options.disableMochaHooks && (0, utils_1.isMochaEachHooks)(hook.title)) {
311
+ if (this._options.disableMochaHooks && isMochaEachHooks(hook.title)) {
301
312
  if (hook.error) {
302
313
  this._allure.endStep('failed');
303
314
  }
@@ -308,14 +319,14 @@ class AllureReporter extends reporter_1.default {
308
319
  }
309
320
  // set hook (test) status
310
321
  if (hook.error) {
311
- if (this._options.disableMochaHooks && (0, utils_1.isMochaAllHooks)(hook.title)) {
322
+ if (this._options.disableMochaHooks && isMochaAllHooks(hook.title)) {
312
323
  this.onTestStart(hook);
313
324
  this.attachScreenshot();
314
325
  }
315
326
  this.onTestFail(hook);
316
327
  }
317
328
  else if (this._options.disableMochaHooks || this._options.useCucumberStepReporter) {
318
- if (!(0, utils_1.isMochaAllHooks)(hook.title)) {
329
+ if (!isMochaAllHooks(hook.title)) {
319
330
  this.onTestPass();
320
331
  // remove hook from suite if it has no steps
321
332
  if (this._allure.getCurrentTest().steps.length === 0 && !this._options.useCucumberStepReporter) {
@@ -369,7 +380,7 @@ class AllureReporter extends reporter_1.default {
369
380
  return false;
370
381
  }
371
382
  const test = this._allure.getCurrentTest();
372
- const issueLink = (0, utils_1.getLinkByTemplate)(this._options.issueLinkTemplate, issue);
383
+ const issueLink = getLinkByTemplate(this._options.issueLinkTemplate, issue);
373
384
  test.addLabel('issue', issueLink);
374
385
  }
375
386
  addTestId({ testId }) {
@@ -377,7 +388,7 @@ class AllureReporter extends reporter_1.default {
377
388
  return false;
378
389
  }
379
390
  const test = this._allure.getCurrentTest();
380
- const tmsLink = (0, utils_1.getLinkByTemplate)(this._options.tmsLinkTemplate, testId);
391
+ const tmsLink = getLinkByTemplate(this._options.tmsLinkTemplate, testId);
381
392
  test.addLabel('testId', tmsLink);
382
393
  }
383
394
  addEnvironment({ name, value }) {
@@ -456,131 +467,131 @@ class AllureReporter extends reporter_1.default {
456
467
  this._lastScreenshot = undefined;
457
468
  }
458
469
  }
470
+ /**
471
+ * Assign feature to test
472
+ * @name addFeature
473
+ * @param {(string)} featureName - feature name or an array of names
474
+ */
475
+ static addFeature = (featureName) => {
476
+ tellReporter(events.addFeature, { featureName });
477
+ };
478
+ /**
479
+ * Assign label to test
480
+ * @name addLabel
481
+ * @param {string} name - label name
482
+ * @param {string} value - label value
483
+ */
484
+ static addLabel = (name, value) => {
485
+ tellReporter(events.addLabel, { name, value });
486
+ };
487
+ /**
488
+ * Assign severity to test
489
+ * @name addSeverity
490
+ * @param {string} severity - severity value
491
+ */
492
+ static addSeverity = (severity) => {
493
+ tellReporter(events.addSeverity, { severity });
494
+ };
495
+ /**
496
+ * Assign issue id to test
497
+ * @name addIssue
498
+ * @param {string} issue - issue id value
499
+ */
500
+ static addIssue = (issue) => {
501
+ tellReporter(events.addIssue, { issue });
502
+ };
503
+ /**
504
+ * Assign TMS test id to test
505
+ * @name addTestId
506
+ * @param {string} testId - test id value
507
+ */
508
+ static addTestId = (testId) => {
509
+ tellReporter(events.addTestId, { testId });
510
+ };
511
+ /**
512
+ * Assign story to test
513
+ * @name addStory
514
+ * @param {string} storyName - story name for test
515
+ */
516
+ static addStory = (storyName) => {
517
+ tellReporter(events.addStory, { storyName });
518
+ };
519
+ /**
520
+ * Add environment value
521
+ * @name addEnvironment
522
+ * @param {string} name - environment name
523
+ * @param {string} value - environment value
524
+ */
525
+ static addEnvironment = (name, value) => {
526
+ tellReporter(events.addEnvironment, { name, value });
527
+ };
528
+ /**
529
+ * Assign test description to test
530
+ * @name addDescription
531
+ * @param {string} description - description for test
532
+ * @param {string} descriptionType - description type 'text'\'html'\'markdown'
533
+ */
534
+ static addDescription = (description, descriptionType) => {
535
+ tellReporter(events.addDescription, { description, descriptionType });
536
+ };
537
+ /**
538
+ * Add attachment
539
+ * @name addAttachment
540
+ * @param {string} name - attachment file name
541
+ * @param {*} content - attachment content
542
+ * @param {string=} mimeType - attachment mime type
543
+ */
544
+ static addAttachment = (name, content, type) => {
545
+ if (!type) {
546
+ type = content instanceof Buffer ? 'image/png' : typeof content === 'string' ? 'text/plain' : 'application/json';
547
+ }
548
+ tellReporter(events.addAttachment, { name, content, type });
549
+ };
550
+ /**
551
+ * Start allure step
552
+ * @name startStep
553
+ * @param {string} title - step name in report
554
+ */
555
+ static startStep = (title) => {
556
+ tellReporter(events.startStep, title);
557
+ };
558
+ /**
559
+ * End current allure step
560
+ * @name endStep
561
+ * @param {StepStatus} [status='passed'] - step status
562
+ */
563
+ static endStep = (status = 'passed') => {
564
+ if (!Object.values(stepStatuses).includes(status)) {
565
+ throw new Error(`Step status must be ${Object.values(stepStatuses).join(' or ')}. You tried to set "${status}"`);
566
+ }
567
+ tellReporter(events.endStep, status);
568
+ };
569
+ /**
570
+ * Create allure step
571
+ * @name addStep
572
+ * @param {string} title - step name in report
573
+ * @param {Object} [attachmentObject={}] - attachment for step
574
+ * @param {string} attachmentObject.content - attachment content
575
+ * @param {string} [attachmentObject.name='attachment'] - attachment name
576
+ * @param {string} [attachmentObject.type='text/plain'] - attachment type
577
+ * @param {string} [status='passed'] - step status
578
+ */
579
+ static addStep = (title, { content, name = 'attachment', type = 'text/plain' } = {}, status = 'passed') => {
580
+ if (!Object.values(stepStatuses).includes(status)) {
581
+ throw new Error(`Step status must be ${Object.values(stepStatuses).join(' or ')}. You tried to set "${status}"`);
582
+ }
583
+ const step = content ? { title, attachment: { content, name, type }, status } : { title, status };
584
+ tellReporter(events.addStep, { step });
585
+ };
586
+ /**
587
+ * Add additional argument to test
588
+ * @name addArgument
589
+ * @param {string} name - argument name
590
+ * @param {string} value - argument value
591
+ */
592
+ static addArgument = (name, value) => {
593
+ tellReporter(events.addArgument, { name, value });
594
+ };
459
595
  }
460
- /**
461
- * Assign feature to test
462
- * @name addFeature
463
- * @param {(string)} featureName - feature name or an array of names
464
- */
465
- AllureReporter.addFeature = (featureName) => {
466
- (0, utils_1.tellReporter)(constants_1.events.addFeature, { featureName });
467
- };
468
- /**
469
- * Assign label to test
470
- * @name addLabel
471
- * @param {string} name - label name
472
- * @param {string} value - label value
473
- */
474
- AllureReporter.addLabel = (name, value) => {
475
- (0, utils_1.tellReporter)(constants_1.events.addLabel, { name, value });
476
- };
477
- /**
478
- * Assign severity to test
479
- * @name addSeverity
480
- * @param {string} severity - severity value
481
- */
482
- AllureReporter.addSeverity = (severity) => {
483
- (0, utils_1.tellReporter)(constants_1.events.addSeverity, { severity });
484
- };
485
- /**
486
- * Assign issue id to test
487
- * @name addIssue
488
- * @param {string} issue - issue id value
489
- */
490
- AllureReporter.addIssue = (issue) => {
491
- (0, utils_1.tellReporter)(constants_1.events.addIssue, { issue });
492
- };
493
- /**
494
- * Assign TMS test id to test
495
- * @name addTestId
496
- * @param {string} testId - test id value
497
- */
498
- AllureReporter.addTestId = (testId) => {
499
- (0, utils_1.tellReporter)(constants_1.events.addTestId, { testId });
500
- };
501
- /**
502
- * Assign story to test
503
- * @name addStory
504
- * @param {string} storyName - story name for test
505
- */
506
- AllureReporter.addStory = (storyName) => {
507
- (0, utils_1.tellReporter)(constants_1.events.addStory, { storyName });
508
- };
509
- /**
510
- * Add environment value
511
- * @name addEnvironment
512
- * @param {string} name - environment name
513
- * @param {string} value - environment value
514
- */
515
- AllureReporter.addEnvironment = (name, value) => {
516
- (0, utils_1.tellReporter)(constants_1.events.addEnvironment, { name, value });
517
- };
518
- /**
519
- * Assign test description to test
520
- * @name addDescription
521
- * @param {string} description - description for test
522
- * @param {string} descriptionType - description type 'text'\'html'\'markdown'
523
- */
524
- AllureReporter.addDescription = (description, descriptionType) => {
525
- (0, utils_1.tellReporter)(constants_1.events.addDescription, { description, descriptionType });
526
- };
527
- /**
528
- * Add attachment
529
- * @name addAttachment
530
- * @param {string} name - attachment file name
531
- * @param {*} content - attachment content
532
- * @param {string=} mimeType - attachment mime type
533
- */
534
- AllureReporter.addAttachment = (name, content, type) => {
535
- if (!type) {
536
- type = content instanceof Buffer ? 'image/png' : typeof content === 'string' ? 'text/plain' : 'application/json';
537
- }
538
- (0, utils_1.tellReporter)(constants_1.events.addAttachment, { name, content, type });
539
- };
540
- /**
541
- * Start allure step
542
- * @name startStep
543
- * @param {string} title - step name in report
544
- */
545
- AllureReporter.startStep = (title) => {
546
- (0, utils_1.tellReporter)(constants_1.events.startStep, title);
547
- };
548
- /**
549
- * End current allure step
550
- * @name endStep
551
- * @param {StepStatus} [status='passed'] - step status
552
- */
553
- AllureReporter.endStep = (status = 'passed') => {
554
- if (!Object.values(constants_1.stepStatuses).includes(status)) {
555
- throw new Error(`Step status must be ${Object.values(constants_1.stepStatuses).join(' or ')}. You tried to set "${status}"`);
556
- }
557
- (0, utils_1.tellReporter)(constants_1.events.endStep, status);
558
- };
559
- /**
560
- * Create allure step
561
- * @name addStep
562
- * @param {string} title - step name in report
563
- * @param {Object} [attachmentObject={}] - attachment for step
564
- * @param {string} attachmentObject.content - attachment content
565
- * @param {string} [attachmentObject.name='attachment'] - attachment name
566
- * @param {string} [attachmentObject.type='text/plain'] - attachment type
567
- * @param {string} [status='passed'] - step status
568
- */
569
- AllureReporter.addStep = (title, { content, name = 'attachment', type = 'text/plain' } = {}, status = 'passed') => {
570
- if (!Object.values(constants_1.stepStatuses).includes(status)) {
571
- throw new Error(`Step status must be ${Object.values(constants_1.stepStatuses).join(' or ')}. You tried to set "${status}"`);
572
- }
573
- const step = content ? { title, attachment: { content, name, type }, status } : { title, status };
574
- (0, utils_1.tellReporter)(constants_1.events.addStep, { step });
575
- };
576
- /**
577
- * Add additional argument to test
578
- * @name addArgument
579
- * @param {string} name - argument name
580
- * @param {string} value - argument value
581
- */
582
- AllureReporter.addArgument = (name, value) => {
583
- (0, utils_1.tellReporter)(constants_1.events.addArgument, { name, value });
584
- };
585
- exports.default = AllureReporter;
586
- __exportStar(require("./types"), exports);
596
+ export default AllureReporter;
597
+ export * from './types.js';
package/build/types.js CHANGED
@@ -1,9 +1,6 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TYPE = void 0;
4
- var TYPE;
1
+ export var TYPE;
5
2
  (function (TYPE) {
6
3
  TYPE["TEXT"] = "text";
7
4
  TYPE["HTML"] = "html";
8
5
  TYPE["MARKDOWN"] = "markdown";
9
- })(TYPE = exports.TYPE || (exports.TYPE = {}));
6
+ })(TYPE || (TYPE = {}));
package/build/utils.d.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  import { HookStats, TestStats } from '@wdio/reporter';
2
2
  import type { Options } from '@wdio/types';
3
- import CompoundError from './compoundError';
4
- import type { Status } from './types';
3
+ import CompoundError from './compoundError.js';
5
4
  import AllureReporter from './index.js';
5
+ import type { Status } from './types';
6
6
  /**
7
7
  * Get allure test status by TestStat object
8
8
  * @param test {Object} - TestStat object
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AACrD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AAE1C,OAAO,aAAa,MAAM,iBAAiB,CAAA;AAE3C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AACrC,OAAO,cAAc,MAAM,YAAY,CAAA;AAEvC;;;;;GAKG;AACH,eAAO,MAAM,aAAa,SAAU,SAAS,GAAG,SAAS,WAAW,QAAQ,UAAU,KAAI,MAiBzF,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,OAAO,WAAY,GAAG,YAAgD,CAAA;AAEnF;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,UAAW,MAAM,YAAsD,CAAA;AAEpG;;;;;GAKG;AACH,eAAO,MAAM,eAAe,UAAW,MAAM,YAAqD,CAAA;AAElG;;;;;GAKG;AACH,eAAO,MAAM,YAAY,UAAW,MAAM,QAAO,GAAG,SAGnD,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,sBAAsB,SAAU,SAAS,GAAG,SAAS,KAAI,KAAK,GAAG,aAAa,GAAG,SAe7F,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,iBAAiB,aAAc,MAAM,GAAG,SAAS,MAAM,MAAM,WAQzE,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,SAAU,MAAM,GAAG,SAAS,UAAU,cAAc,CAAC,SAAS,CAAC,SAS5F,CAAA"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AACrD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AAE1C,OAAO,aAAa,MAAM,oBAAoB,CAAA;AAE9C,OAAO,cAAc,MAAM,YAAY,CAAA;AACvC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAErC;;;;;GAKG;AACH,eAAO,MAAM,aAAa,SAAU,SAAS,GAAG,SAAS,WAAW,QAAQ,UAAU,KAAI,MAiBzF,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,OAAO,WAAY,GAAG,YAAgD,CAAA;AAEnF;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,UAAW,MAAM,YAAsD,CAAA;AAEpG;;;;;GAKG;AACH,eAAO,MAAM,eAAe,UAAW,MAAM,YAAqD,CAAA;AAElG;;;;;GAKG;AACH,eAAO,MAAM,YAAY,UAAW,MAAM,QAAO,GAAG,SAGnD,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,sBAAsB,SAAU,SAAS,GAAG,SAAS,KAAI,KAAK,GAAG,aAAa,GAAG,SAe7F,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,iBAAiB,aAAc,MAAM,GAAG,SAAS,MAAM,MAAM,WAQzE,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,SAAU,MAAM,GAAG,SAAS,UAAU,cAAc,CAAC,SAAS,CAAC,SAS5F,CAAA"}
package/build/utils.js CHANGED
@@ -1,20 +1,14 @@
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.attachConsoleLogs = exports.getLinkByTemplate = exports.getErrorFromFailedTest = exports.tellReporter = exports.isMochaAllHooks = exports.isMochaEachHooks = exports.isEmpty = exports.getTestStatus = void 0;
7
- const process_1 = __importDefault(require("process"));
8
- const strip_ansi_1 = __importDefault(require("strip-ansi"));
9
- const compoundError_1 = __importDefault(require("./compoundError"));
10
- const constants_1 = require("./constants");
1
+ import process from 'node:process';
2
+ import stripAnsi from 'strip-ansi';
3
+ import CompoundError from './compoundError.js';
4
+ import { mochaEachHooks, mochaAllHooks, linkPlaceholder } from './constants.js';
11
5
  /**
12
6
  * Get allure test status by TestStat object
13
7
  * @param test {Object} - TestStat object
14
8
  * @param config {Object} - wdio config object
15
9
  * @private
16
10
  */
17
- const getTestStatus = (test, config) => {
11
+ export const getTestStatus = (test, config) => {
18
12
  if (config && config.framework === 'jasmine') {
19
13
  return 'failed';
20
14
  }
@@ -30,66 +24,60 @@ const getTestStatus = (test, config) => {
30
24
  }
31
25
  return 'broken';
32
26
  };
33
- exports.getTestStatus = getTestStatus;
34
27
  /**
35
28
  * Check is object is empty
36
29
  * @param object {Object}
37
30
  * @private
38
31
  */
39
- const isEmpty = (object) => !object || Object.keys(object).length === 0;
40
- exports.isEmpty = isEmpty;
32
+ export const isEmpty = (object) => !object || Object.keys(object).length === 0;
41
33
  /**
42
34
  * Is mocha beforeEach / afterEach hook
43
35
  * @param title {String} - hook title
44
36
  * @returns {boolean}
45
37
  * @private
46
38
  */
47
- const isMochaEachHooks = (title) => constants_1.mochaEachHooks.some(hook => title.includes(hook));
48
- exports.isMochaEachHooks = isMochaEachHooks;
39
+ export const isMochaEachHooks = (title) => mochaEachHooks.some(hook => title.includes(hook));
49
40
  /**
50
41
  * Is mocha beforeAll / afterAll hook
51
42
  * @param title {String} - hook title
52
43
  * @returns {boolean}
53
44
  * @private
54
45
  */
55
- const isMochaAllHooks = (title) => constants_1.mochaAllHooks.some(hook => title.includes(hook));
56
- exports.isMochaAllHooks = isMochaAllHooks;
46
+ export const isMochaAllHooks = (title) => mochaAllHooks.some(hook => title.includes(hook));
57
47
  /**
58
48
  * Call reporter
59
49
  * @param {string} event - event name
60
50
  * @param {Object} msg - event payload
61
51
  * @private
62
52
  */
63
- const tellReporter = (event, msg = {}) => {
53
+ export const tellReporter = (event, msg = {}) => {
64
54
  // Node 14 typings does not accept string in process.emit, but allow string in process.on
65
- process_1.default.emit(event, msg);
55
+ process.emit(event, msg);
66
56
  };
67
- exports.tellReporter = tellReporter;
68
57
  /**
69
58
  * Properly format error from different test runners
70
59
  * @param {Object} test - TestStat object
71
60
  * @returns {Object} - error object
72
61
  * @private
73
62
  */
74
- const getErrorFromFailedTest = (test) => {
63
+ export const getErrorFromFailedTest = (test) => {
75
64
  if (test.errors && Array.isArray(test.errors)) {
76
65
  for (let i = 0; i < test.errors.length; i += 1) {
77
66
  if (test.errors[i].message)
78
- test.errors[i].message = (0, strip_ansi_1.default)(test.errors[i].message);
67
+ test.errors[i].message = stripAnsi(test.errors[i].message);
79
68
  if (test.errors[i].stack)
80
- test.errors[i].stack = (0, strip_ansi_1.default)(test.errors[i].stack);
69
+ test.errors[i].stack = stripAnsi(test.errors[i].stack);
81
70
  }
82
- return test.errors.length === 1 ? test.errors[0] : new compoundError_1.default(...test.errors);
71
+ return test.errors.length === 1 ? test.errors[0] : new CompoundError(...test.errors);
83
72
  }
84
73
  if (test.error) {
85
74
  if (test.error.message)
86
- test.error.message = (0, strip_ansi_1.default)(test.error.message);
75
+ test.error.message = stripAnsi(test.error.message);
87
76
  if (test.error.stack)
88
- test.error.stack = (0, strip_ansi_1.default)(test.error.stack);
77
+ test.error.stack = stripAnsi(test.error.stack);
89
78
  }
90
79
  return test.error;
91
80
  };
92
- exports.getErrorFromFailedTest = getErrorFromFailedTest;
93
81
  /**
94
82
  * Substitute task id to link template
95
83
  * @param {string} template - link template
@@ -97,26 +85,24 @@ exports.getErrorFromFailedTest = getErrorFromFailedTest;
97
85
  * @returns {string} - link after substitution
98
86
  * @private
99
87
  */
100
- const getLinkByTemplate = (template, id) => {
88
+ export const getLinkByTemplate = (template, id) => {
101
89
  if (typeof template !== 'string') {
102
90
  return id;
103
91
  }
104
- if (!template.includes(constants_1.linkPlaceholder)) {
105
- throw Error(`The link template "${template}" must contain ${constants_1.linkPlaceholder} substring.`);
92
+ if (!template.includes(linkPlaceholder)) {
93
+ throw Error(`The link template "${template}" must contain ${linkPlaceholder} substring.`);
106
94
  }
107
- return template.replace(constants_1.linkPlaceholder, id);
95
+ return template.replace(linkPlaceholder, id);
108
96
  };
109
- exports.getLinkByTemplate = getLinkByTemplate;
110
97
  /**
111
98
  *
112
99
  * @param {string} logs - logs to be attached
113
100
  * @param {string} allure - allure report object
114
101
  * @private
115
102
  */
116
- const attachConsoleLogs = (logs, allure) => {
103
+ export const attachConsoleLogs = (logs, allure) => {
117
104
  if (logs) {
118
- allure === null || allure === void 0 ? void 0 : allure.addAttachment('Console Logs', '<pre style="display: inline-block; background-color: #4d4d4d; color: white; padding: 20px; text-shadow: 1px 1px 0 #444; min-width: 100%; height: auto; min-height: 100%;">'
105
+ allure?.addAttachment('Console Logs', '<pre style="display: inline-block; background-color: #4d4d4d; color: white; padding: 20px; text-shadow: 1px 1px 0 #444; min-width: 100%; height: auto; min-height: 100%;">'
119
106
  + '.........Console Logs.........\n\n' + logs + '</pre>', 'text/html');
120
107
  }
121
108
  };
122
- exports.attachConsoleLogs = attachConsoleLogs;
package/package.json CHANGED
@@ -1,18 +1,14 @@
1
1
  {
2
2
  "name": "@wdio/allure-reporter",
3
- "version": "7.20.7",
3
+ "version": "7.20.8-alpha.504+428a9d729",
4
4
  "description": "A WebdriverIO reporter plugin to create Allure Test Reports",
5
5
  "author": "Boris Osipov <osipov.boris@gmail.com>",
6
6
  "homepage": "https://github.com/webdriverio/webdriverio/tree/main/packages/wdio-allure-reporter",
7
7
  "license": "MIT",
8
- "main": "./build/index",
9
- "engines": {
10
- "node": ">=12.0.0"
11
- },
12
- "types": "./build/index.d.ts",
13
8
  "repository": {
14
9
  "type": "git",
15
- "url": "git://github.com/webdriverio/webdriverio.git"
10
+ "url": "git://github.com/webdriverio/webdriverio.git",
11
+ "directory": "packages/wdio-allure-reporter"
16
12
  },
17
13
  "keywords": [
18
14
  "webdriver",
@@ -23,19 +19,25 @@
23
19
  "bugs": {
24
20
  "url": "https://github.com/webdriverio/webdriverio/issues"
25
21
  },
22
+ "type": "module",
23
+ "exports": "./build/index.js",
24
+ "types": "./build/index.d.ts",
25
+ "typeScriptVersion": "3.8.3",
26
+ "engines": {
27
+ "node": "^16.13 || >=18"
28
+ },
26
29
  "dependencies": {
27
- "@types/node": "^18.0.0",
28
- "@wdio/reporter": "7.20.7",
29
- "@wdio/types": "7.20.7",
30
+ "@wdio/reporter": "7.20.8-alpha.504+428a9d729",
31
+ "@wdio/types": "7.20.8-alpha.504+428a9d729",
30
32
  "allure-js-commons": "^1.3.2",
31
33
  "csv-stringify": "^6.0.4",
32
34
  "strip-ansi": "^6.0.0"
33
35
  },
34
- "peerDependencies": {
35
- "@wdio/cli": "^7.0.0"
36
+ "devDependencies": {
37
+ "@types/node": "^18.0.0"
36
38
  },
37
39
  "publishConfig": {
38
40
  "access": "public"
39
41
  },
40
- "gitHead": "21b8b61453f4749d87eca3e4d7d6e5e2cb60f043"
42
+ "gitHead": "428a9d729ae6231968a60908732fa3f607d195e9"
41
43
  }