@wdio/allure-reporter 8.36.0 → 8.37.0

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.
@@ -21,7 +21,7 @@ export declare const events: {
21
21
  readonly addArgument: "allure:addArgument";
22
22
  readonly addAllureStep: "allure:addAllureStep";
23
23
  };
24
- export declare const mochaEachHooks: readonly ["\"before each\" hook", "\"after each\" hook"];
25
- export declare const mochaAllHooks: readonly ["\"before all\" hook", "\"after all\" hook"];
24
+ export declare const eachHooks: readonly ["\"before each\" hook", "\"after each\" hook"];
25
+ export declare const allHooks: readonly ["\"before all\" hook", "\"after all\" hook"];
26
26
  export declare const linkPlaceholder = "{}";
27
27
  //# sourceMappingURL=constants.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;;;CAsBT,CAAA;AAEV,eAAO,MAAM,cAAc,0DAAuD,CAAA;AAClF,eAAO,MAAM,aAAa,wDAAqD,CAAA;AAC/E,eAAO,MAAM,eAAe,OAAO,CAAA"}
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;;;CAsBT,CAAA;AAEV,eAAO,MAAM,SAAS,0DAAuD,CAAA;AAC7E,eAAO,MAAM,QAAQ,wDAAqD,CAAA;AAC1E,eAAO,MAAM,eAAe,OAAO,CAAA"}
@@ -21,6 +21,6 @@ export const events = {
21
21
  addArgument: 'allure:addArgument',
22
22
  addAllureStep: 'allure:addAllureStep'
23
23
  };
24
- export const mochaEachHooks = ['"before each" hook', '"after each" hook'];
25
- export const mochaAllHooks = ['"before all" hook', '"after all" hook'];
24
+ export const eachHooks = ['"before each" hook', '"after each" hook'];
25
+ export const allHooks = ['"before all" hook', '"after all" hook'];
26
26
  export const linkPlaceholder = '{}';
@@ -1,8 +1,8 @@
1
1
  /// <reference types="node" resolution-mode="require"/>
2
2
  import type { SuiteStats, HookStats, RunnerStats, TestStats, BeforeCommandArgs, AfterCommandArgs } from '@wdio/reporter';
3
3
  import WDIOReporter from '@wdio/reporter';
4
- import type { MetadataMessage, AllureStep } from 'allure-js-commons';
5
- import { AllureGroup, AllureTest, Status as AllureStatus, Stage, ContentType } from 'allure-js-commons';
4
+ import type { MetadataMessage } from 'allure-js-commons';
5
+ import { AllureGroup, AllureTest, Status as AllureStatus, Stage, ContentType, AllureStep } from 'allure-js-commons';
6
6
  import { addFeature, addLink, addOwner, addEpic, addSuite, addSubSuite, addParentSuite, addTag, addLabel, addSeverity, addIssue, addTestId, addStory, addAllureId, addDescription, addAttachment, startStep, endStep, addStep, addArgument, step } from './common/api.js';
7
7
  import { AllureReporterState } from './state.js';
8
8
  import type { AddAttachmentEventArgs, AddDescriptionEventArgs, AddFeatureEventArgs, AddIssueEventArgs, AddLabelEventArgs, AddSeverityEventArgs, AddEpicEventArgs, AddOwnerEventArgs, AddParentSuiteEventArgs, AddSubSuiteEventArgs, AddLinkEventArgs, AddAllureIdEventArgs, AddSuiteEventArgs, AddTagEventArgs, AddStoryEventArgs, AddTestIdEventArgs, AllureReporterOptions } from './types.js';
@@ -1 +1 @@
1
- {"version":3,"file":"reporter.d.ts","sourceRoot":"","sources":["../src/reporter.ts"],"names":[],"mappings":";AACA,OAAO,KAAK,EACR,UAAU,EAAE,SAAS,EAAE,WAAW,EAAE,SAAS,EAAE,iBAAiB,EAChE,gBAAgB,EACnB,MAAM,gBAAgB,CAAA;AACvB,OAAO,YAAY,MAAM,gBAAgB,CAAA;AAEzC,OAAO,KAAK,EAAS,eAAe,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAC3E,OAAO,EACY,WAAW,EAAE,UAAU,EAAE,MAAM,IAAI,YAAY,EAAE,KAAK,EAC3D,WAAW,EACxB,MAAM,mBAAmB,CAAA;AAC1B,OAA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AQ5B,OAAO,CAAC,EACJ,IAAI,EACP,EAAE,GAAG;IAcN,WAAW,CAAC,EACR,IAAI,EACJ,KAAK,EACR,EAAE,GAAG;IAQN,aAAa,CAAC,QAAQ,EAAE,eAAe;IAgDvC;;;OAGG;IACH,MAAM,CAAC,UAAU,oBAAa;IAC9B,MAAM,CAAC,OAAO,iBAAU;IACxB,MAAM,CAAC,OAAO,iBAAU;IACxB,MAAM,CAAC,QAAQ,kBAAW;IAC1B,MAAM,CAAC,MAAM,gBAAS;IACtB,MAAM,CAAC,QAAQ,kBAAW;IAC1B,MAAM,CAAC,WAAW,qBAAc;IAChC,MAAM,CAAC,QAAQ,kBAAW;IAC1B,MAAM,CAAC,QAAQ,kBAAW;IAC1B,MAAM,CAAC,WAAW,qBAAc;IAChC,MAAM,CAAC,cAAc,wBAAiB;IACtC,MAAM,CAAC,SAAS,mBAAY;IAC5B,MAAM,CAAC,QAAQ,kBAAW;IAC1B,MAAM,CAAC,cAAc,wBAAiB;IACtC,MAAM,CAAC,aAAa,uBAAgB;IACpC,MAAM,CAAC,SAAS,mBAAY;IAC5B,MAAM,CAAC,OAAO,iBAAU;IACxB,MAAM,CAAC,OAAO,iBAAU;IACxB,MAAM,CAAC,WAAW,qBAAc;IAChC,MAAM,CAAC,WAAW,qBAAc;IAChC,MAAM,CAAC,IAAI,cAAO;CACrB"}
package/build/reporter.js CHANGED
@@ -1,9 +1,9 @@
1
1
  import { stringify } from 'csv-stringify/sync';
2
2
  import WDIOReporter from '@wdio/reporter';
3
- import { AllureRuntime, AllureGroup, AllureTest, Status as AllureStatus, Stage, LabelName, LinkType, ContentType, AllureCommandStepExecutable, } from 'allure-js-commons';
3
+ import { AllureRuntime, AllureGroup, AllureTest, Status as AllureStatus, Stage, LabelName, LinkType, ContentType, AllureCommandStepExecutable, ExecutableItemWrapper, AllureStep, Status } from 'allure-js-commons';
4
4
  import { addFeature, addLink, addOwner, addEpic, addSuite, addSubSuite, addParentSuite, addTag, addLabel, addSeverity, addIssue, addTestId, addStory, addAllureId, addDescription, addAttachment, startStep, endStep, addStep, addArgument, step, } from './common/api.js';
5
5
  import { AllureReporterState } from './state.js';
6
- import { getTestStatus, isEmpty, isMochaEachHooks, getErrorFromFailedTest, isMochaAllHooks, getLinkByTemplate, isScreenshotCommand, getSuiteLabels, setAllureIds, isMochaBeforeEachHook, } from './utils.js';
6
+ import { getTestStatus, isEmpty, isEachTypeHooks, getErrorFromFailedTest, isAllTypeHooks, getLinkByTemplate, isScreenshotCommand, getSuiteLabels, setAllureIds, isBeforeTypeHook, cleanCucumberHooks, getHookStatus } from './utils.js';
7
7
  import { events } from './constants.js';
8
8
  import { TYPE as DescriptionType } from './types.js';
9
9
  export default class AllureReporter extends WDIOReporter {
@@ -44,21 +44,21 @@ export default class AllureReporter extends WDIOReporter {
44
44
  reportedEnvironmentVars && this._allure.writeEnvironmentInfo(reportedEnvironmentVars);
45
45
  }
46
46
  attachLogs() {
47
- if (!this._consoleOutput || !this._state.currentAllureTestOrStep) {
47
+ if (!this._consoleOutput || !this._state.currentAllureStepableEntity) {
48
48
  return;
49
49
  }
50
50
  const logsContent = `.........Console Logs.........\n\n${this._consoleOutput}`;
51
51
  const attachmentFilename = this._allure.writeAttachment(logsContent, ContentType.TEXT);
52
- this._state.currentAllureTestOrStep.addAttachment('Console Logs', {
52
+ this._state.currentAllureStepableEntity.addAttachment('Console Logs', {
53
53
  contentType: ContentType.TEXT,
54
54
  }, attachmentFilename);
55
55
  }
56
56
  attachFile(name, content, contentType) {
57
- if (!this._state.currentAllureTestOrStep) {
57
+ if (!this._state.currentAllureStepableEntity) {
58
58
  throw new Error("There isn't any active test!");
59
59
  }
60
60
  const attachmentFilename = this._allure.writeAttachment(content, contentType);
61
- this._state.currentAllureTestOrStep.addAttachment(name, {
61
+ this._state.currentAllureStepableEntity.addAttachment(name, {
62
62
  contentType,
63
63
  }, attachmentFilename);
64
64
  }
@@ -79,25 +79,33 @@ export default class AllureReporter extends WDIOReporter {
79
79
  if (!this._state.currentSuite) {
80
80
  throw new Error("There isn't any active suite!");
81
81
  }
82
- while (this._state.currentAllureTestOrStep) {
83
- const currentTest = this._state.pop();
84
- const isAnyStepFailed = currentTest.wrappedItem.steps.some((step) => step.status === AllureStatus.FAILED);
85
- const isAnyStepBroken = currentTest.wrappedItem.steps.some((step) => step.status === AllureStatus.BROKEN);
86
- currentTest.stage = Stage.FINISHED;
87
- currentTest.status = isAnyStepFailed
88
- ? AllureStatus.FAILED
89
- : isAnyStepBroken
90
- ? AllureStatus.BROKEN
91
- : AllureStatus.PASSED;
92
- if (currentTest instanceof AllureTest) {
93
- setAllureIds(currentTest, this._state.currentSuite);
94
- currentTest.endTest();
82
+ while (this._state.currentAllureStepableEntity) {
83
+ const currentElement = this._state.pop();
84
+ if (!(currentElement instanceof AllureGroup)) {
85
+ const isAnyStepFailed = currentElement.wrappedItem.steps.some((step) => step.status === AllureStatus.FAILED);
86
+ const isAnyStepBroken = currentElement.wrappedItem.steps.some((step) => step.status === AllureStatus.BROKEN);
87
+ currentElement.stage = Stage.FINISHED;
88
+ currentElement.status = isAnyStepFailed
89
+ ? AllureStatus.FAILED
90
+ : isAnyStepBroken
91
+ ? AllureStatus.BROKEN
92
+ : AllureStatus.PASSED;
95
93
  }
96
- else {
97
- currentTest.endStep();
94
+ if (currentElement instanceof AllureTest) {
95
+ setAllureIds(currentElement, this._state.currentSuite);
96
+ currentElement.endTest();
97
+ }
98
+ else if (currentElement instanceof AllureStep) {
99
+ currentElement.endStep();
98
100
  }
99
101
  }
100
102
  const currentSuite = this._state.pop();
103
+ // if a hook were execute without a test the report will need a test to display the hook
104
+ if (this._state.stats.hooks > 0 && this._state.stats.test === 0) {
105
+ const test = currentSuite.startTest(currentSuite.name);
106
+ test.status = Status.BROKEN;
107
+ test.endTest();
108
+ }
101
109
  currentSuite.endGroup();
102
110
  }
103
111
  _startTest(testTitle, cid) {
@@ -107,7 +115,7 @@ export default class AllureReporter extends WDIOReporter {
107
115
  this.setTestParameters(cid);
108
116
  }
109
117
  _skipTest() {
110
- if (!this._state.currentAllureTestOrStep) {
118
+ if (!this._state.currentAllureStepableEntity) {
111
119
  return;
112
120
  }
113
121
  const currentTest = this._state.pop();
@@ -122,7 +130,7 @@ export default class AllureReporter extends WDIOReporter {
122
130
  }
123
131
  }
124
132
  _endTest(status, error, stage) {
125
- if (!this._state.currentAllureTestOrStep) {
133
+ if (!this._state.currentAllureStepableEntity) {
126
134
  return;
127
135
  }
128
136
  const currentSpec = this._state.pop();
@@ -131,20 +139,24 @@ export default class AllureReporter extends WDIOReporter {
131
139
  if (error) {
132
140
  currentSpec.detailsMessage = error.message;
133
141
  currentSpec.detailsTrace = error.stack;
142
+ // if some step or sub step fails the current test will fails.
143
+ if (this._state.currentTest) {
144
+ this._state.currentTest.statusDetails = { message: error.message, trace: error.stack };
145
+ }
134
146
  }
135
147
  if (currentSpec instanceof AllureTest) {
136
148
  setAllureIds(currentSpec, this._state.currentSuite);
137
149
  currentSpec.endTest();
138
150
  }
139
- else {
151
+ else if (currentSpec instanceof AllureStep) {
140
152
  currentSpec.endStep();
141
153
  }
142
154
  }
143
155
  _startStep(testTitle) {
144
- if (!this._state.currentAllureTestOrStep) {
145
- throw new Error("There isn't any active test!");
156
+ if (!this._state.currentAllureStepableEntity) {
157
+ throw new Error('There are no active steppable entities!');
146
158
  }
147
- const newStep = this._state.currentAllureTestOrStep.startStep(testTitle);
159
+ const newStep = this._state.currentAllureStepableEntity.startStep(testTitle);
148
160
  this._state.push(newStep);
149
161
  }
150
162
  setTestParameters(cid) {
@@ -226,7 +238,7 @@ export default class AllureReporter extends WDIOReporter {
226
238
  const isScenario = suite.type === 'scenario';
227
239
  const isFeature = suite.type === 'feature';
228
240
  this._state.currentFile = suite.file;
229
- // handle cucumber scenario as allure "case" instead of "suite"
241
+ // handle a cucumber scenario as allure "case" instead of "suite"
230
242
  if (useCucumberStepReporter && isScenario) {
231
243
  this._startTest(suite.title, suite.cid);
232
244
  getSuiteLabels(suite).forEach((label) => {
@@ -278,6 +290,13 @@ export default class AllureReporter extends WDIOReporter {
278
290
  // A scenario is it passed if certain steps are passed and all other are skipped and every hooks are passed or skipped
279
291
  const isPartiallySkipped = suiteChildren.every(item => [AllureStatus.PASSED, AllureStatus.SKIPPED].includes(item.state));
280
292
  if (isPassed || isPartiallySkipped) {
293
+ // const currentTest = this._state.pop() as AllureTest
294
+ // const currentTest = this._state.currentTest as AllureTest
295
+ //
296
+ // currentTest.status = AllureStatus.PASSED
297
+ // currentTest.stage = Stage.FINISHED
298
+ // setHistoryId(currentTest, this._state.currentSuite)
299
+ // setAllureIds(currentTest, this._state.currentSuite)
281
300
  this._endTest(AllureStatus.PASSED);
282
301
  return;
283
302
  }
@@ -319,27 +338,32 @@ export default class AllureReporter extends WDIOReporter {
319
338
  this._endTest(testStatus, getErrorFromFailedTest(test));
320
339
  return;
321
340
  }
322
- if (!this._state.currentAllureTestOrStep) {
341
+ if (!this._state.currentAllureStepableEntity) {
323
342
  this.onTestStart(test);
324
343
  }
325
- else {
326
- this._state.currentAllureTestOrStep.name = test.title;
344
+ else if (this._state.currentAllureStepableEntity instanceof AllureTest) {
345
+ this._state.currentAllureStepableEntity.name = test.title;
327
346
  }
328
347
  this.attachLogs();
329
348
  const status = getTestStatus(test, this._config);
330
349
  this._endTest(status, getErrorFromFailedTest(test));
331
350
  }
332
351
  onTestSkip(test) {
352
+ const { useCucumberStepReporter } = this._options;
333
353
  this.attachLogs();
334
- if (!this._state.currentAllureTestOrStep || this._state.currentAllureTestOrStep.wrappedItem.name !== test.title) {
335
- this._startTest(test.title, test.cid);
336
- this._skipTest();
337
- return;
354
+ if (!this._state.currentAllureStepableEntity || this._state.currentAllureStepableEntity.wrappedItem.name !==
355
+ test.title) {
356
+ if (useCucumberStepReporter) {
357
+ this.onTestStart(test);
358
+ }
359
+ else {
360
+ this._startTest(test.title, test.cid);
361
+ }
338
362
  }
339
363
  this._skipTest();
340
364
  }
341
365
  onBeforeCommand(command) {
342
- if (!this._state.currentAllureTestOrStep) {
366
+ if (!this._state.currentAllureStepableEntity) {
343
367
  return;
344
368
  }
345
369
  const { disableWebdriverStepsReporting } = this._options;
@@ -367,74 +391,134 @@ export default class AllureReporter extends WDIOReporter {
367
391
  this.endStep(AllureStatus.PASSED);
368
392
  }
369
393
  onHookStart(hook) {
370
- const { disableMochaHooks } = this._options;
371
- // ignore global hooks
372
- if (!hook.parent || !this._state.currentSuite) {
394
+ const { disableMochaHooks, useCucumberStepReporter } = this._options;
395
+ // ignore global hooks or hooks when option is set in false
396
+ // any hook is skipped if there is not a suite created.
397
+ if (!hook.parent || !this._state.currentSuite || disableMochaHooks) {
373
398
  return;
374
399
  }
375
- const isMochaAllHook = isMochaAllHooks(hook.title);
376
- const isMochaEachHook = isMochaEachHooks(hook.title);
377
- // don't add hook as test to suite for mocha each hooks if no current test
378
- if (disableMochaHooks && isMochaEachHook && !this._state.currentAllureTestOrStep) {
379
- return;
400
+ const isAllHook = isAllTypeHooks(hook.title); // if the hook is beforeAll or afterAll for mocha/jasmine
401
+ const isEachHook = isEachTypeHooks(hook.title); // if the hook is beforeEach or afterEach for mocha/jasmine
402
+ // if the hook is before/after from mocha/jasmine
403
+ if (isAllHook || isEachHook) {
404
+ const hookExecutable = isBeforeTypeHook(hook.title)
405
+ ? this._state.currentSuite.addBefore()
406
+ : this._state.currentSuite.addAfter();
407
+ const hookStep = hookExecutable.startStep(hook.title);
408
+ this._state.push(hookExecutable);
409
+ this._state.push(hookStep);
410
+ // if the hook is custom by default, it will be reported as test (not usual)
380
411
  }
381
- // add beforeEach / afterEach hook as step to test
382
- if (disableMochaHooks && isMochaEachHook && this._state.currentAllureTestOrStep) {
383
- this._startStep(hook.title);
384
- return;
412
+ else if (!(isAllHook || isEachHook) && !useCucumberStepReporter) {
413
+ const customHookTest = this._state.currentSuite.startTest(`hook:${hook.title}`);
414
+ this._state.push(customHookTest);
415
+ // hooks in cucumber mode will be treated as Test/Step
385
416
  }
386
- // don't add hook as test to suite for mocha All hooks
387
- if (disableMochaHooks && isMochaAllHook) {
388
- return;
417
+ else if (useCucumberStepReporter) {
418
+ this.onTestStart(hook);
389
419
  }
390
- // add hook as test to suite
391
- this.onTestStart(hook);
392
420
  }
393
421
  onHookEnd(hook) {
394
422
  const { disableMochaHooks, useCucumberStepReporter } = this._options;
395
423
  // ignore global hooks
424
+ // any hook is skipped if there is not a suite created.
396
425
  if (!hook.parent || !this._state.currentSuite) {
397
426
  return;
398
427
  }
399
- const isMochaAllHook = isMochaAllHooks(hook.title);
400
- const isMochaEachHook = isMochaEachHooks(hook.title);
401
- if (disableMochaHooks && !isMochaAllHook && !this._state.currentAllureTestOrStep) {
402
- return;
403
- }
404
- // set beforeEach / afterEach hook (step) status
405
- if (disableMochaHooks && isMochaEachHook) {
406
- this._endTest(hook.error ? AllureStatus.FAILED : AllureStatus.PASSED, hook.error);
407
- // mocha doesn't fire onTestEnd for failed beforeEach hook
408
- // we have to force mark test as failed test
409
- if (isMochaBeforeEachHook(hook.title) && hook.error) {
410
- const fakeTestStat = Object.assign({}, hook, { title: hook.currentTest });
411
- this._endTest(fakeTestStat.error ? AllureStatus.FAILED : AllureStatus.PASSED, fakeTestStat.error);
428
+ const isAllHook = isAllTypeHooks(hook.title); // if the hook is beforeAll or afterAll for mocha/jasmine
429
+ const isEachHook = isEachTypeHooks(hook.title); // if the hook is beforeEach or afterEach for mocha/jasmine
430
+ /****
431
+ * if the hook is before/after from mocha/jasmine and disableMochaHooks=false.
432
+ */
433
+ // if the hook is before/after from mocha/jasmine and disableMochaHooks=false.
434
+ if ((isAllHook || isEachHook) && !disableMochaHooks) {
435
+ // getting the hook root step, and the hook element from stack.
436
+ const currentHookRootStep = this._state.pop();
437
+ const currentHookRoot = this._state.pop();
438
+ // check if the elements exist
439
+ if (currentHookRootStep || currentHookRoot) {
440
+ // check if the elements related to hook
441
+ if (currentHookRootStep instanceof AllureStep &&
442
+ currentHookRoot instanceof ExecutableItemWrapper) {
443
+ getHookStatus(hook, currentHookRoot, currentHookRootStep);
444
+ currentHookRootStep.endStep();
445
+ if (isBeforeTypeHook(hook.title) && (hook.error || hook.errors?.length)) {
446
+ this._startTest(hook.currentTest || hook.title, hook.cid);
447
+ this._endTest(AllureStatus.BROKEN, getErrorFromFailedTest(hook));
448
+ }
449
+ return;
450
+ }
451
+ // put them back to the list
452
+ if (currentHookRoot) {
453
+ this._state.push(currentHookRoot);
454
+ }
455
+ if (currentHookRootStep) {
456
+ this._state.push(currentHookRootStep);
457
+ }
412
458
  }
413
- return;
414
459
  }
415
- if (hook.error) {
416
- // add hook as test to suite for mocha all hooks, when it didn't start before
417
- if (disableMochaHooks && isMochaAllHook) {
460
+ /****
461
+ * if the hook is before/after from mocha/jasmine or cucumber by setting useCucumberStepReporter=true,
462
+ * and disableMochaHooks=true with a failed hook.
463
+ *
464
+ * Only if the hook fails, it will be reported.
465
+ */
466
+ if (disableMochaHooks && hook.error) {
467
+ // hook is from cucumber
468
+ if (useCucumberStepReporter) {
469
+ // report a new allure hook (step)
418
470
  this.onTestStart(hook);
471
+ // set the hook as failed one
472
+ this.onTestFail(hook);
473
+ // remove cucumber hook (reported as step) from suite if it has no steps or attachments.
474
+ const currentItem = this._state.currentAllureStepableEntity?.wrappedItem;
475
+ if (currentItem) {
476
+ cleanCucumberHooks(currentItem);
477
+ }
478
+ return;
419
479
  }
420
- this.onTestFail(hook);
421
- // mocha doesn't fire onTestEnd for failed beforeEach hook
422
- // we have to force mark test as failed test
423
- if (isMochaBeforeEachHook(hook.title) && !disableMochaHooks) {
424
- this.onTestFail(Object.assign({}, hook, { title: hook.currentTest }));
480
+ // hook is before/after from mocha/jasmine
481
+ const hookExecutable = isBeforeTypeHook(hook.title)
482
+ ? this._state.currentSuite.addBefore()
483
+ : this._state.currentSuite.addAfter();
484
+ const hookStep = hookExecutable.startStep(hook.title);
485
+ // register the hook
486
+ this._state.stats.hooks++;
487
+ // updating the hook information
488
+ getHookStatus(hook, hookExecutable, hookStep);
489
+ hookStep.endStep();
490
+ return;
491
+ }
492
+ /****
493
+ * if the hook is not before/after from mocha/jasmine (custom hook) and useCucumberStepReporter=false
494
+ * Custom hooks are not affected by "disableMochaHooks" option
495
+ */
496
+ if (!(isAllHook || isEachHook) && !useCucumberStepReporter) {
497
+ // getting the latest element
498
+ const lastElement = this._state.pop();
499
+ if (lastElement) {
500
+ const isCustomHook = lastElement instanceof AllureTest &&
501
+ lastElement.wrappedItem.name?.startsWith('hook:');
502
+ this._state.push(lastElement);
503
+ if (isCustomHook) {
504
+ // we end the test case (custom hook) that represents the custom hook call.
505
+ this._endTest(getTestStatus(hook), hook.error);
506
+ }
425
507
  }
426
508
  return;
427
509
  }
428
- this.onTestPass();
429
- if (useCucumberStepReporter) {
430
- // remove hook from suite if it has no steps or attachments
431
- const currentItem = this._state.currentAllureTestOrStep?.wrappedItem;
510
+ /****
511
+ * if the hook comes from Cucumber useCucumberStepReporter=true
512
+ */
513
+ if (useCucumberStepReporter && !disableMochaHooks) {
514
+ // closing the cucumber hook (in this case, it's reported as a step)
515
+ hook.error ? this.onTestFail(hook) : this.onTestPass();
516
+ // remove cucumber hook (reported as a step) from a suite if it has no steps or attachments.
517
+ const currentItem = this._state.currentAllureStepableEntity?.wrappedItem;
432
518
  if (currentItem) {
433
- const currentStep = currentItem.steps[currentItem.steps.length - 1];
434
- if (currentStep.steps.length === 0 && currentStep.attachments.length === 0 && currentItem.attachments.length === 0) {
435
- currentItem.steps.pop();
436
- }
519
+ cleanCucumberHooks(currentItem);
437
520
  }
521
+ return;
438
522
  }
439
523
  }
440
524
  addLabel({ name, value }) {
@@ -550,7 +634,7 @@ export default class AllureReporter extends WDIOReporter {
550
634
  this._state.currentTest.description = description;
551
635
  }
552
636
  addAttachment({ name, content, type = ContentType.TEXT }) {
553
- if (!this._state.currentTest) {
637
+ if (!this._state.currentAllureStepableEntity) {
554
638
  return;
555
639
  }
556
640
  if (type === ContentType.JSON) {
@@ -560,19 +644,19 @@ export default class AllureReporter extends WDIOReporter {
560
644
  this.attachFile(name, Buffer.from(content), type);
561
645
  }
562
646
  startStep(title) {
563
- if (!this._state.currentAllureTestOrStep) {
647
+ if (!this._state.currentAllureStepableEntity) {
564
648
  return;
565
649
  }
566
650
  this._startStep(title);
567
651
  }
568
652
  endStep(status) {
569
- if (!this._state.currentAllureTestOrStep) {
653
+ if (!this._state.currentAllureStepableEntity) {
570
654
  return;
571
655
  }
572
656
  this._endTest(status);
573
657
  }
574
658
  addStep({ step }) {
575
- if (!this._state.currentAllureTestOrStep) {
659
+ if (!this._state.currentAllureStepableEntity) {
576
660
  return;
577
661
  }
578
662
  this._startStep(step.title);
@@ -588,7 +672,7 @@ export default class AllureReporter extends WDIOReporter {
588
672
  this._state.currentTest.addParameter(name, value);
589
673
  }
590
674
  addAllureStep(metadata) {
591
- const { currentAllureTestOrStep: currentAllureSpec } = this._state;
675
+ const { currentAllureStepableEntity: currentAllureSpec } = this._state;
592
676
  if (!currentAllureSpec) {
593
677
  throw new Error("Couldn't add step: no test case running!");
594
678
  }
package/build/state.d.ts CHANGED
@@ -1,13 +1,20 @@
1
- import { AllureGroup, AllureTest, AllureStep } from 'allure-js-commons';
1
+ import { AllureGroup, AllureTest, AllureStep, ExecutableItemWrapper } from 'allure-js-commons';
2
+ import type { AllureStepableUnit } from './types.js';
2
3
  export declare class AllureReporterState {
3
4
  currentFile?: string;
4
- runningUnits: Array<AllureGroup | AllureTest | AllureStep>;
5
+ runningUnits: Array<AllureGroup | AllureStepableUnit>;
6
+ stats: {
7
+ test: number;
8
+ hooks: number;
9
+ suites: number;
10
+ };
5
11
  get currentSuite(): AllureGroup | undefined;
6
12
  get currentTest(): AllureTest | undefined;
7
13
  get currentStep(): AllureStep | undefined;
8
- get currentAllureTestOrStep(): AllureTest | AllureStep | undefined;
14
+ get currentHook(): ExecutableItemWrapper | undefined;
15
+ get currentAllureStepableEntity(): AllureStepableUnit | undefined;
9
16
  get currentPackageLabel(): string | undefined;
10
- push(unit: AllureGroup | AllureTest | AllureStep): void;
11
- pop(): AllureGroup | AllureTest | AllureStep | undefined;
17
+ push(unit: AllureGroup | AllureStepableUnit): void;
18
+ pop(): AllureGroup | AllureStepableUnit | undefined;
12
19
  }
13
20
  //# sourceMappingURL=state.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../src/state.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAGvE,qBAAa,mBAAmB;IAC5B,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,YAAY,EAAE,KAAK,CAAC,WAAW,GAAG,UAAU,GAAG,UAAU,CAAC,CAAK;IAE/D,IAAI,YAAY,IAAI,WAAW,GAAG,SAAS,CAE1C;IAED,IAAI,WAAW,IAAI,UAAU,GAAG,SAAS,CAExC;IAED,IAAI,WAAW,IAAI,UAAU,GAAG,SAAS,CAExC;IAED,IAAI,uBAAuB,IAAI,UAAU,GAAG,UAAU,GAAG,SAAS,CAEjE;IAED,IAAI,mBAAmB,IAAI,MAAM,GAAG,SAAS,CAM5C;IAED,IAAI,CAAC,IAAI,EAAE,WAAW,GAAG,UAAU,GAAG,UAAU;IAIhD,GAAG,IAAI,WAAW,GAAG,UAAU,GAAG,UAAU,GAAG,SAAS;CAG3D"}
1
+ {"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../src/state.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,UAAU,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAA;AAE9F,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;AAEpD,qBAAa,mBAAmB;IAC5B,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,YAAY,EAAE,KAAK,CAAC,WAAW,GAAG,kBAAkB,CAAC,CAAK;IAC1D,KAAK,EAAE;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAC,CAAmC;IAEvF,IAAI,YAAY,IAAI,WAAW,GAAG,SAAS,CAE1C;IAED,IAAI,WAAW,IAAI,UAAU,GAAG,SAAS,CAExC;IAED,IAAI,WAAW,IAAI,UAAU,GAAG,SAAS,CAExC;IAED,IAAI,WAAW,IAAI,qBAAqB,GAAG,SAAS,CAEnD;IAED,IAAI,2BAA2B,IAAI,kBAAkB,GAAG,SAAS,CAEhE;IAED,IAAI,mBAAmB,IAAI,MAAM,GAAG,SAAS,CAM5C;IAED,IAAI,CAAC,IAAI,EAAE,WAAW,GAAG,kBAAkB;IAW3C,GAAG,IAAI,WAAW,GAAG,kBAAkB,GAAG,SAAS;CAGtD"}
package/build/state.js CHANGED
@@ -1,9 +1,10 @@
1
1
  import { sep } from 'node:path';
2
- import { AllureGroup, AllureTest, AllureStep } from 'allure-js-commons';
2
+ import { AllureGroup, AllureTest, AllureStep, ExecutableItemWrapper } from 'allure-js-commons';
3
3
  import { findLast } from './utils.js';
4
4
  export class AllureReporterState {
5
5
  currentFile;
6
6
  runningUnits = [];
7
+ stats = { test: 0, hooks: 0, suites: 0 };
7
8
  get currentSuite() {
8
9
  return findLast(this.runningUnits, (unit) => unit instanceof AllureGroup);
9
10
  }
@@ -13,8 +14,11 @@ export class AllureReporterState {
13
14
  get currentStep() {
14
15
  return findLast(this.runningUnits, (unit) => unit instanceof AllureStep);
15
16
  }
16
- get currentAllureTestOrStep() {
17
- return findLast(this.runningUnits, (unit) => unit instanceof AllureTest || unit instanceof AllureStep);
17
+ get currentHook() {
18
+ return findLast(this.runningUnits, (unit) => unit instanceof ExecutableItemWrapper);
19
+ }
20
+ get currentAllureStepableEntity() {
21
+ return findLast(this.runningUnits, (unit) => unit instanceof AllureTest || unit instanceof AllureStep || unit instanceof ExecutableItemWrapper);
18
22
  }
19
23
  get currentPackageLabel() {
20
24
  if (!this.currentFile) {
@@ -23,6 +27,15 @@ export class AllureReporterState {
23
27
  return this.currentFile.replaceAll(sep, '.');
24
28
  }
25
29
  push(unit) {
30
+ if (unit instanceof AllureGroup) {
31
+ this.stats.suites++;
32
+ }
33
+ else if (unit instanceof AllureTest) {
34
+ this.stats.test++;
35
+ }
36
+ else {
37
+ this.stats.hooks++;
38
+ }
26
39
  this.runningUnits.push(unit);
27
40
  }
28
41
  pop() {
package/build/types.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import type { AllureStep, AllureTest, ExecutableItemWrapper } from 'allure-js-commons';
1
2
  /**
2
3
  * When you add a new option, please also update the docs at ./packages/wdio-allure-reporter/README.md
3
4
  */
@@ -123,6 +124,7 @@ export interface Attachment {
123
124
  end(status: Status, error: Error, timestamp?: number): void;
124
125
  toXML(): string;
125
126
  }
127
+ export type AllureStepableUnit = AllureTest | AllureStep | ExecutableItemWrapper;
126
128
  declare global {
127
129
  namespace WebdriverIO {
128
130
  interface ReporterOption extends AllureReporterOptions {
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,qBAAqB;IAClC;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB;;;OAGG;IACH,uBAAuB,CAAC,EAAE,OAAO,CAAA;IACjC;;;OAGG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAA;IAC3B;;OAEG;IACH,8BAA8B,CAAC,EAAE,OAAO,CAAA;IACxC;;OAEG;IACH,oCAAoC,CAAC,EAAE,OAAO,CAAA;IAC9C;;;;OAIG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAC1B;;;OAGG;IACH,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB;;;MAGE;IACF,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB;;;MAGE;IACF,uBAAuB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CACnD;AAED,MAAM,WAAW,iBAAiB;IAC9B,IAAI,EAAE,MAA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OAAO,CAAC,MAAM,CAAC;IACX,UAAU,WAAW,CAAC;QAClB,UAAU,cAAe,SAAQ,qBAAqB;SAAI;KAC7D;CACJ"}
package/build/utils.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import type { HookStats, TestStats, SuiteStats, CommandArgs } from '@wdio/reporter';
2
2
  import type { Options } from '@wdio/types';
3
- import type { Label, AllureTest, AllureGroup } from 'allure-js-commons';
3
+ import type { AllureGroup, AllureStep, AllureTest, ExecutableItemWrapper, FixtureResult, Label, TestResult } from 'allure-js-commons';
4
4
  import { Status as AllureStatus } from 'allure-js-commons';
5
5
  import CompoundError from './compoundError.js';
6
6
  /**
@@ -17,26 +17,33 @@ export declare const getTestStatus: (test: TestStats | HookStats, config?: Optio
17
17
  */
18
18
  export declare const isEmpty: (object: any) => boolean;
19
19
  /**
20
- * Is mocha beforeEach hook
20
+ * Is mocha/jasmine beforeEach hook
21
21
  * @param title {String} - hook title
22
22
  * @returns {boolean}
23
23
  * @private
24
24
  */
25
- export declare const isMochaBeforeEachHook: (title: string) => boolean;
25
+ export declare const isBeforeEachTypeHook: (title: string) => boolean;
26
26
  /**
27
- * Is mocha beforeEach / afterEach hook
27
+ * Is mocha/jasmine beforeAll / beforeEach hook
28
28
  * @param title {String} - hook title
29
29
  * @returns {boolean}
30
30
  * @private
31
31
  */
32
- export declare const isMochaEachHooks: (title: string) => boolean;
32
+ export declare const isBeforeTypeHook: (title: string) => boolean;
33
33
  /**
34
- * Is mocha beforeAll / afterAll hook
34
+ * Is mocha/jasmine beforeEach / afterEach hook
35
35
  * @param title {String} - hook title
36
36
  * @returns {boolean}
37
37
  * @private
38
38
  */
39
- export declare const isMochaAllHooks: (title: string) => boolean;
39
+ export declare const isEachTypeHooks: (title: string) => boolean;
40
+ /**
41
+ * Is mocha/jasmine beforeAll / afterAll hook
42
+ * @param title {String} - hook title
43
+ * @returns {boolean}
44
+ * @private
45
+ */
46
+ export declare const isAllTypeHooks: (title: string) => boolean;
40
47
  /**
41
48
  * Properly format error from different test runners
42
49
  * @param {object} test - TestStat object
@@ -44,6 +51,16 @@ export declare const isMochaAllHooks: (title: string) => boolean;
44
51
  * @private
45
52
  */
46
53
  export declare const getErrorFromFailedTest: (test: TestStats | HookStats) => Error | CompoundError | undefined;
54
+ /**
55
+ * Update the hook information with the new one, it could be use when a hook ends
56
+ * @param {HookStats} newHookStats - New information that will be applied to current hook info
57
+ * @param {ExecutableItemWrapper} hookElement - hook element registered in the report
58
+ * @param {AllureStep} hookRootStep - root hook step
59
+ *
60
+ * @private
61
+ */
62
+ export declare const getHookStatus: (newHookStats: HookStats, hookElement: ExecutableItemWrapper, hookRootStep: AllureStep) => void;
63
+ export declare const cleanCucumberHooks: (hook: FixtureResult | TestResult) => void;
47
64
  /**
48
65
  * Substitute task id to link template
49
66
  * @param {string} template - link template
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,UAAU,EAAE,WAAW,EAAO,MAAM,gBAAgB,CAAA;AACxF,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AAC1C,OAAO,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AACvE,OAAO,EAAE,MAAM,IAAI,YAAY,EAAkB,MAAM,mBAAmB,CAAA;AAC1E,OAAO,aAAa,MAAM,oBAAoB,CAAA;AAG9C;;;;;GAKG;AACH,eAAO,MAAM,aAAa,SAChB,SAAS,GAAG,SAAS,WAClB,QAAQ,UAAU,KAC5B,YA0BF,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,OAAO,WAAY,GAAG,YACY,CAAA;AAE/C;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,UAAW,MAAM,YACd,CAAA;AAErC;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,UAAW,MAAM,YACS,CAAA;AAEvD;;;;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AAoB,UAAW,MAAM,YAClB,CAAA;AAEhC;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,UAAW,MAAM,YACiB,CAAA;AAE/D;;;;;GAKG;AACH,eAAO,MAAM,eAAe,UAAW,MAAM,YACK,CAAA;AAElD;;;;;GAKG;AACH,eAAO,MAAM,cAAc,UAAW,MAAM,YACK,CAAA;AAEjD;;;;;GAKG;AACH,eAAO,MAAM,sBAAsB,SACzB,SAAS,GAAG,SAAS,KAC5B,KAAK,GAAG,aAAa,GAAG,SAyB1B,CAAA;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,aAAa,iBAAkB,SAAS,eAAe,qBAAqB,gBAAgB,UAAU,SA+BlH,CAAA;AAED,eAAO,MAAM,kBAAkB,SAAW,aAAa,GAAG,UAAU,SAWnE,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,iBAAiB,aAAc,MAAM,GAAG,SAAS,MAAM,MAAM,WAYzE,CAAA;AAED,eAAO,MAAM,QAAQ,WACZ,MAAM,CAAC,CAAC,aACF,CAAC,EAAE,EAAE,CAAC,KAAK,OAAO,KAC9B,CAAC,GAAG,SAWN,CAAA;AAED,eAAO,MAAM,mBAAmB,YAAa,WAAW,KAAG,OAS1D,CAAA;AAED,eAAO,MAAM,cAAc,aAAc,UAAU,KAAG,KAAK,EAc1D,CAAA;AAED,eAAO,MAAM,YAAY,SAAU,UAAU,GAAG,SAAS,SAAS,WAAW,GAAG,SAAS,SAkBxF,CAAA"}
package/build/utils.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import stripAnsi from 'strip-ansi';
2
- import { Status as AllureStatus, md5, LabelName } from 'allure-js-commons';
2
+ import { LabelName, md5, Stage, Status, Status as AllureStatus } from 'allure-js-commons';
3
3
  import CompoundError from './compoundError.js';
4
- import { mochaEachHooks, mochaAllHooks, linkPlaceholder } from './constants.js';
4
+ import { allHooks, eachHooks, linkPlaceholder } from './constants.js';
5
5
  /**
6
6
  * Get allure test status by TestStat object
7
7
  * @param test {Object} - TestStat object
@@ -28,6 +28,9 @@ export const getTestStatus = (test, config) => {
28
28
  : AllureStatus.BROKEN;
29
29
  }
30
30
  }
31
+ else if (test.errors) {
32
+ return AllureStatus.FAILED;
33
+ }
31
34
  return AllureStatus.BROKEN;
32
35
  };
33
36
  /**
@@ -37,26 +40,33 @@ export const getTestStatus = (test, config) => {
37
40
  */
38
41
  export const isEmpty = (object) => !object || Object.keys(object).length === 0;
39
42
  /**
40
- * Is mocha beforeEach hook
43
+ * Is mocha/jasmine beforeEach hook
41
44
  * @param title {String} - hook title
42
45
  * @returns {boolean}
43
46
  * @private
44
47
  */
45
- export const isMochaBeforeEachHook = (title) => title.includes(mochaEachHooks[0]);
48
+ export const isBeforeEachTypeHook = (title) => title.includes(eachHooks[0]);
46
49
  /**
47
- * Is mocha beforeEach / afterEach hook
50
+ * Is mocha/jasmine beforeAll / beforeEach hook
48
51
  * @param title {String} - hook title
49
52
  * @returns {boolean}
50
53
  * @private
51
54
  */
52
- export const isMochaEachHooks = (title) => mochaEachHooks.some((hook) => title.includes(hook));
55
+ export const isBeforeTypeHook = (title) => title.includes(allHooks[0]) || title.includes(eachHooks[0]);
53
56
  /**
54
- * Is mocha beforeAll / afterAll hook
57
+ * Is mocha/jasmine beforeEach / afterEach hook
55
58
  * @param title {String} - hook title
56
59
  * @returns {boolean}
57
60
  * @private
58
61
  */
59
- export const isMochaAllHooks = (title) => mochaAllHooks.some((hook) => title.includes(hook));
62
+ export const isEachTypeHooks = (title) => eachHooks.some((hook) => title.includes(hook));
63
+ /**
64
+ * Is mocha/jasmine beforeAll / afterAll hook
65
+ * @param title {String} - hook title
66
+ * @returns {boolean}
67
+ * @private
68
+ */
69
+ export const isAllTypeHooks = (title) => allHooks.some((hook) => title.includes(hook));
60
70
  /**
61
71
  * Properly format error from different test runners
62
72
  * @param {object} test - TestStat object
@@ -64,7 +74,7 @@ export const isMochaAllHooks = (title) => mochaAllHooks.some((hook) => title.inc
64
74
  * @private
65
75
  */
66
76
  export const getErrorFromFailedTest = (test) => {
67
- if (test.errors && Array.isArray(test.errors)) {
77
+ if (test.errors && Array.isArray(test.errors) && test.errors.length) {
68
78
  for (let i = 0; i < test.errors.length; i += 1) {
69
79
  if (test.errors[i].message) {
70
80
  test.errors[i].message = stripAnsi(test.errors[i].message);
@@ -87,6 +97,55 @@ export const getErrorFromFailedTest = (test) => {
87
97
  }
88
98
  return test.error;
89
99
  };
100
+ /**
101
+ * Update the hook information with the new one, it could be use when a hook ends
102
+ * @param {HookStats} newHookStats - New information that will be applied to current hook info
103
+ * @param {ExecutableItemWrapper} hookElement - hook element registered in the report
104
+ * @param {AllureStep} hookRootStep - root hook step
105
+ *
106
+ * @private
107
+ */
108
+ export const getHookStatus = (newHookStats, hookElement, hookRootStep) => {
109
+ // stage to finish for all hook.
110
+ hookElement.stage = hookRootStep.stage =
111
+ Stage.FINISHED;
112
+ // set error detail information
113
+ const formattedError = getErrorFromFailedTest(newHookStats);
114
+ hookElement.detailsMessage = hookRootStep.detailsMessage = formattedError?.message;
115
+ hookElement.detailsTrace = hookRootStep.detailsTrace = formattedError?.stack;
116
+ let finalStatus = Status.PASSED;
117
+ // set status to hook root step
118
+ const hookSteps = hookRootStep.wrappedItem.steps;
119
+ if (Array.isArray(hookSteps) && hookSteps.length) {
120
+ const statusPriority = {
121
+ [Status.FAILED]: 0,
122
+ [Status.BROKEN]: 1,
123
+ [Status.SKIPPED]: 2,
124
+ [Status.PASSED]: 3,
125
+ };
126
+ let stepStatus = Status.PASSED;
127
+ for (const step of hookSteps) {
128
+ if (step.status && statusPriority[step.status] < statusPriority[finalStatus]) {
129
+ stepStatus = step.status;
130
+ }
131
+ }
132
+ finalStatus = stepStatus === Status.FAILED ? Status.BROKEN : stepStatus;
133
+ }
134
+ else if (newHookStats.error || (Array.isArray(newHookStats.errors) && newHookStats.errors.length)) {
135
+ finalStatus = Status.BROKEN;
136
+ }
137
+ hookElement.status = hookRootStep.status = finalStatus;
138
+ };
139
+ export const cleanCucumberHooks = (hook) => {
140
+ const currentStep = hook.steps[hook.steps.length - 1];
141
+ if (currentStep &&
142
+ currentStep.steps.length === 0 &&
143
+ currentStep.attachments.length === 0 &&
144
+ hook.attachments.length === 0 &&
145
+ currentStep.status === Status.PASSED) {
146
+ hook.steps.pop();
147
+ }
148
+ };
90
149
  /**
91
150
  * Substitute task id to link template
92
151
  * @param {string} template - link template
package/cjs/constants.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.linkPlaceholder = exports.mochaAllHooks = exports.mochaEachHooks = exports.events = void 0;
3
+ exports.linkPlaceholder = exports.allHooks = exports.eachHooks = exports.events = void 0;
4
4
  exports.events = {
5
5
  addLabel: 'allure:addLabel',
6
6
  addLink: 'allure:addLink',
@@ -24,6 +24,6 @@ exports.events = {
24
24
  addArgument: 'allure:addArgument',
25
25
  addAllureStep: 'allure:addAllureStep'
26
26
  };
27
- exports.mochaEachHooks = ['"before each" hook', '"after each" hook'];
28
- exports.mochaAllHooks = ['"before all" hook', '"after all" hook'];
27
+ exports.eachHooks = ['"before each" hook', '"after each" hook'];
28
+ exports.allHooks = ['"before all" hook', '"after all" hook'];
29
29
  exports.linkPlaceholder = '{}';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wdio/allure-reporter",
3
- "version": "8.36.0",
3
+ "version": "8.37.0",
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",
@@ -40,8 +40,8 @@
40
40
  },
41
41
  "dependencies": {
42
42
  "@types/node": "^20.1.0",
43
- "@wdio/reporter": "8.36.0",
44
- "@wdio/types": "8.36.0",
43
+ "@wdio/reporter": "8.37.0",
44
+ "@wdio/types": "8.37.0",
45
45
  "allure-js-commons": "^2.5.0",
46
46
  "csv-stringify": "^6.0.4",
47
47
  "strip-ansi": "^7.1.0"
@@ -49,5 +49,5 @@
49
49
  "publishConfig": {
50
50
  "access": "public"
51
51
  },
52
- "gitHead": "bc4e87f18f8f3cd8293734264f3ffb1e6a194cd7"
52
+ "gitHead": "cefb415aa315075fb6b682c6d059d9ff37fbefb8"
53
53
  }