Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[🐛 Bug]: afterTest hook is getting called with wrong test when test is timed out #12595

Open
3 tasks done
sriteja777 opened this issue Mar 29, 2024 · 1 comment
Open
3 tasks done
Labels
Bug 🐛 help wanted Issues that are free to take by anyone interested

Comments

@sriteja777
Copy link
Contributor

Have you read the Contributing Guidelines on issues?

WebdriverIO Version

8.35.1

Node.js Version

20.11.1

Mode

WDIO Testrunner

Which capabilities are you using?

{
   browserName: 'chrome'
}

What happened?

Let's say if we have two tests test1 and test2 and we have async hooks defined - beforeTest and afterTest
When a test test1 gets timed out, the afterTest hook is getting called with wrong test test2 two times instead of getting called for test1 and test2. In logs we can the below logs

[0-0] beforeTest called for test test 1
[0-0] beforeTest called for test test 2
[0-0] afterTest called for test test 2 with error - Error: Timeout
[0-0] afterTest called for test test 2 with error - Error: Timeout

What is your expected behavior?

  • beforeTest for test2 should get called after the afterTest for test1 gets called
  • afterTest should get called for both test1 and test2

How to reproduce the bug.

Reproducible example: https://github.com/sriteja777/wdio_timeout_issue

Just clone the repo and run the tests - npm run wdio. You can observe in logs that afterTest is getting called for test2 two times.

Relevant log output

Execution of 1 workers started at 2024-03-29T05:04:43.131Z

[0-0] RUNNING in chrome - file:///test/specs/test.e2e.js
[0-0] beforeTest called for test test 1
[0-0] Error in "My Login application.test 1"
Error: Timeout of 1000ms exceeded. The execution in the test "My Login application test 1" took too long. Try to reduce the run time or increase your timeout for test specs (https://webdriver.io/docs/timeouts). (/Users/sriteja/central_sdk/wdio/timeout_issue/test/specs/test.e2e.js)
    at createTimeoutError (/Users/sriteja/central_sdk/wdio/timeout_issue/node_modules/mocha/lib/errors.js:498:15)
    at Runnable._timeoutError (/Users/sriteja/central_sdk/wdio/timeout_issue/node_modules/mocha/lib/runnable.js:431:10)
    at Timeout.<anonymous> (/Users/sriteja/central_sdk/wdio/timeout_issue/node_modules/mocha/lib/runnable.js:246:24)
    at listOnTimeout (node:internal/timers:573:17)
    at process.processTimers (node:internal/timers:514:7)
[0-0] beforeTest called for test test 2
[0-0] afterTest called for test test 2 with error - Error: Timeout
[0-0] Error in "My Login application.test 2"
Error: Timeout of 1000ms exceeded. The execution in the test "My Login application test 2" took too long. Try to reduce the run time or increase your timeout for test specs (https://webdriver.io/docs/timeouts). (/Users/sriteja/central_sdk/wdio/timeout_issue/test/specs/test.e2e.js)
    at createTimeoutError (/Users/sriteja/central_sdk/wdio/timeout_issue/node_modules/mocha/lib/errors.js:498:15)
    at Runnable._timeoutError (/Users/sriteja/central_sdk/wdio/timeout_issue/node_modules/mocha/lib/runnable.js:431:10)
    at Timeout.<anonymous> (/Users/sriteja/central_sdk/wdio/timeout_issue/node_modules/mocha/lib/runnable.js:246:24)
    at listOnTimeout (node:internal/timers:573:17)
    at process.processTimers (node:internal/timers:514:7)
[0-0] afterTest called for test test 2 with error - Error: Timeout
[0-0] FAILED in chrome - file:///test/specs/test.e2e.js

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
@sriteja777 sriteja777 added Bug 🐛 Needs Triaging ⏳ No one has looked into the issue yet labels Mar 29, 2024
@christian-bromann christian-bromann added help wanted Issues that are free to take by anyone interested and removed Needs Triaging ⏳ No one has looked into the issue yet labels Mar 29, 2024
@wdio-bot
Copy link
Contributor

Thanks for reporting!

We greatly appreciate any contributions that help resolve the bug. While we understand that active contributors have their own priorities, we kindly request your assistance if you rely on this bug being fixed. We encourage you to take a look at our contribution guidelines or join our friendly Discord development server, where you can ask any questions you may have. Thank you for your support, and cheers!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug 🐛 help wanted Issues that are free to take by anyone interested
Projects
None yet
Development

No branches or pull requests

3 participants