Skip to content

[🐛 Bug]: Custom command triggers only Reporter.onAfterCommand without the onBeforeCommand breaking reports #14580

@dprevost-LMI

Description

@dprevost-LMI

Have you read the Contributing Guidelines on issues?

WebdriverIO Version

9.15.0

Node.js Version

18

Mode

Standalone Mode

Which capabilities are you using?

N/A

What happened?

Since we introduced the driver custom command, our reports are broken, and the startStep/EndStep no longer displays correctly. Our steps ended prematurely, and we encountered unusual errors during and after our tests.

After debugging, I found that it is due to the new driver custom command we introduced, which triggers only the onAfterCommand on the reporter and closes a step not related to that command.

The root cause is this code line in monad.ts emitting result without prior command. Moreover, it should also send a result on error.

See potential fix: #14581

What is your expected behavior?

All emit to result should have one prior on command and also should be wrap in a try-catch so that on error we garantee a result emit

How to reproduce the bug.

  • Have a driver custom command
  • User startStep from allure
  • call your custom command
  • The custom command will end your step before you can call end step

Relevant log output

[0-0] Error in "reporter CustomAllureReporter"
Error: There isn't any active test!
    at GoToAllureReporter._endSuite (/redacted/config/webDriverIO/reporters/allure-reporter/allureReporter.ts:568:13)
    at GoToAllureReporter.onSuiteEnd (/redacted/config/webDriverIO/reporters/allure-reporter/allureReporter.ts:504:10)
    at GoToAllureReporter.<anonymous> (/redacted/node_modules/@wdio/reporter/build/index.cjs:615:12)
    at GoToAllureReporter.emit (node:events:517:28)
    at GoToAllureReporter.emit (node:domain:489:12)
    at file:///redacted/node_modules/@wdio/runner/build/index.js:508:18
    at Array.forEach (<anonymous>)
    at BaseReporter.emit (file:///redacted/node_modules/@wdio/runner/build/index.js:506:21)
    at MochaAdapter.emit (/redacted/node_modules/@wdio/mocha-framework/build/index.js:281:20)
    at Runner.emit (node:events:529:35)

Code of Conduct

  • I agree to follow this project's Code of Conduct

Is there an existing issue for this?

  • I have searched the existing issues

Metadata

Metadata

Assignees

Labels

Bug 🐛help wantedIssues that are free to take by anyone interested

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions