webdriverio / webdriverio/webdriverio

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

Open
#14,314 2 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

help wanted Idea 💡
Dominant language
TypeScript
Stars
9.8k
Forks
2.7k
Avg merge
2d 13h
Merged PRs (30d)
69

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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The issue names the afterTest hook and Mocha's context.test.callback; start by tracing how afterTest receives the result object and how Mocha records final status. Done should include supported status changes from the hook, with tests covering a failed post-test check and a retry that later passes without leaving the run failed.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
testing-qa
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.