webdriverio/webdriverio

[馃挕 Feature]: Ability to set the test status from the afterTest hook

Open

#14314 opened on Mar 24, 2025

View on GitHub
聽(2 comments)聽(1 reaction)聽(0 assignees)JavaScript聽(6,029 stars)聽(1,793 forks)batch import
Idea 馃挕help wanted

Description

Is your feature request related to a problem?

I would like to be able to set the status of a test from the afterTest hook. In some cases it makes sense to do a check at the end of a test to determine if the test failed. For instance, checking the browser console log to see if any errors happened during test execution.

Describe the solution you'd like.

An easy way to set the status of a test from the afterTest hook, possibly just by changing the result object?

Describe alternatives you've considered.

No response

Additional context

Currently this does not seem possible (at least with Mocha). You can not change the test status after the test has already finished. There seems to be an option that does somewhat what I am looking for, which is calling the context.test.callback method. This does cause the test to fail, but with the "wrong" reason that the done method is called twice. It also has the problem that when a test is retried after a failure and then passes, the test runner process will still exit with an error even though all tests are green.

Code of Conduct

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

Contributor guide