webdriverio/webdriverio

[🐛 Bug]: Thrown Error In A Test Stops WDIO From Running

Open

#14,216 opened on 2025年2月21日

GitHub で見る
 (10 comments) (0 reactions) (0 assignees)JavaScript (6,029 stars) (1,793 forks)batch import
Bug 🐛help wanted

説明

Have you read the Contributing Guidelines on issues?

WebdriverIO Version

v9.9.3

Node.js Version

v20.11.0

Mode

WDIO Testrunner

Which capabilities are you using?

// Not sure if the bug is related to capabilities but here is what's in my wdio.conf.js

{
    browserName: "chrome",
}

What happened?

When a test is running and it throws an error (regardless of whether it's caught in a catch block or not) wdio just stops and doesn't go through the rest of the tests.

What is your expected behavior?

In the terminal where the wdio test runner is run, I should see this summary towards the end:

"spec" Reporter:

[chrome 133.0.6943.127 mac #0-0] Running: chrome (v133.0.6943.127) on mac [chrome 133.0.6943.127 mac #0-0] Session ID: 3f778a02b48c2c263c2ab9c6ed38eea6 [chrome 133.0.6943.127 mac #0-0] [chrome 133.0.6943.127 mac #0-0] » file:///test/test.js [chrome 133.0.6943.127 mac #0-0] Dummy Test [chrome 133.0.6943.127 mac #0-0] ✓ Just Passes [chrome 133.0.6943.127 mac #0-0] ✖ Dummy Test [chrome 133.0.6943.127 mac #0-0] ✓ Just Passes Again [chrome 133.0.6943.127 mac #0-0] [chrome 133.0.6943.127 mac #0-0] 2 passing (925ms) [chrome 133.0.6943.127 mac #0-0] 1 failing [chrome 133.0.6943.127 mac #0-0] [chrome 133.0.6943.127 mac #0-0] 1) Dummy Test Dummy Test [chrome 133.0.6943.127 mac #0-0] Failed to fetch [chrome 133.0.6943.127 mac #0-0] TypeError: Failed to fetch [chrome 133.0.6943.127 mac #0-0] at sendPostRequestNoCatch

How to reproduce the bug.

I have a mini sample project here: https://github.com/HassHz/sampleworkspace/tree/errorNoSummary All it does is make wdio run a test.js. In the "Dummy Test" I make it do a POST request to a non-existent location to make it throw an error.

To setup and run this project, do the following:

  1. Clone the repo to your machine.
  2. Switch to the errorNoSummary branch (git checkout errorNoSummary).
  3. Run yarn to install dependecies.
  4. Run yarn test

You can go into https://github.com/HassHz/sampleworkspace/blob/errorNoSummary/test/test.js#L29 and change the option to 1 or 2 before running yarn test. It's set to 2 because that reproduces the issue more frequently.

You might have to run yarn test multiple times until the issue is reproduced since the behaviour is a bit inconsistent at times.

Relevant log output

[0-0] 2025-02-21T20:53:03.492Z INFO webdriver: RESULT [
[0-0]   {
[0-0]     level: 'SEVERE',
[0-0]     message: 'https://nonexistent.com/api - Failed to load resource: net::ERR_NAME_NOT_RESOLVED',
[0-0]     source: 'network',
[0-0]     timestamp: 1740171183017
[0-0]   },
[0-0]   {
[0-0]     level: 'SEVERE',
[0-0]     message: 'http://localhost:50110/@fs/Users/pocampo/dev/werkout/another/sampleworkspace/node_modules/@wdio/browser-runner/build/browser/driver.js?import 240:6 "Error:" TypeError: Failed to fetch\n' +
[0-0]       '    at sendPostRequest (http://localhost:50110/Users/pocampo/dev/werkout/another/sampleworkspace/test/test.js:3:28)\n' +
[0-0]       '    at Context.<anonymous> (http://localhost:50110/Users/pocampo/dev/werkout/another/sampleworkspace/test/test.js:52:13)\n' +
[0-0]       '    at Context.executeAsync (http://localhost:50110/node_modules/@wdio/utils/build/index.js?v=b1903df7:1005:10)\n' +
[0-0]       '    at Context.testFrameworkFnWrapper (http://localhost:50110/node_modules/@wdio/utils/build/index.js?v=b1903df7:1075:34)',
[0-0]     source: 'console-api',
[0-0]     timestamp: 1740171183081
[0-0]   }
[0-0] ]
[0-0]  Error:  Test failed due to following error(s):
  - api: Failed to load resource: net::ERR_NAME_NOT_RESOLVED

  - index.js?v=b1903df7:1075:34): undefined

[0-0] 2025-02-21T20:53:03.493Z INFO webdriver: COMMAND deleteSession()
[0-0] 2025-02-21T20:53:03.493Z INFO webdriver: [DELETE] http://localhost:50117/session/7fc1357a0f87d2f6f6a60c460678a250
[0-0] 2025-02-21T20:53:03.547Z INFO webdriver: RESULT null
[0-0] 2025-02-21T20:53:03.547Z INFO webdriver: Kill driver process with PID 60243
[0-0] FAILED in chrome - file:///test/test.js
2025-02-21T20:53:03.666Z INFO @wdio/cli:launcher: Run onWorkerEnd hook

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

コントリビューターガイド