Skip to content

[🐛 Bug]: Total Spec Files and % Completed are not updated when tests are dynamically added during onPrepare event #14095

@mauriciolauffer

Description

@mauriciolauffer

Have you read the Contributing Guidelines on issues?

WebdriverIO Version

latest

Node.js Version

22.11.0

Mode

WDIO Testrunner

Which capabilities are you using?

What happened?

I have a plugin, wdio-qunit-service, which dynamically add spec files to wdio runtime using onPrepare hook which is executed before beforeSession. For instance, the app I want to test has ZERO spec/test files, but when I run $ wdio run wdio.conf.js my plugin dynamically add one. The following code is basically how I'm doing it: https://github.com/mauriciolauffer/wdio-qunit-service/blob/3071484e43b22e4d1ac21f1d71a308cba1b76f47/src/index.ts#L122-L132

class CustomLauncher implements Services.ServiceInstance {
  onPrepare(config: WebdriverIO.Config): void {
    // something something
    config.specs?.push(join(getDirname(), "default.test.js"));
  }
}

Everything works fine, the dynamically added spec files are executed and show up in the reports. However, the total spec files and % completed are not updated. In the screenshot, you can see: 1 passed, 0 total (0% completed) in 00:00:29. Would we have a way to also update these numbers?

Image

I noticed that the number of workers at the beginning of the execution is also not updating: Execution of 0 workers started at 2025-01-22T12:04:42.742Z. In both log messages, the value comes from the same variable.

Image

What is your expected behavior?

Both Execution of 0 workers started at 2025-01-22T12:04:42.742Z and 1 passed, 0 total (0% completed) in 00:00:29 should take in consideration specs dynamically added to the execution.

How to reproduce the bug.

You can test it in my project.

Clone the project repo.

Run $

pnpm i

Then run $

pnpm test:no:specs

Relevant log output

Call stack when `# of workers` is set:


Launcher.run (c:\zdev\wdio-qunit-service\node_modules\.pnpm\@wdio+cli@9.5.7\node_modules\@wdio\cli\build\index.js:2176)
await (Unknown Source:0)
launch (c:\zdev\wdio-qunit-service\node_modules\.pnpm\@wdio+cli@9.5.7\node_modules\@wdio\cli\build\index.js:3109)
handler3 (c:\zdev\wdio-qunit-service\node_modules\.pnpm\@wdio+cli@9.5.7\node_modules\@wdio\cli\build\index.js:3144)
await (Unknown Source:0)
<anonymous> (c:\zdev\wdio-qunit-service\node_modules\.pnpm\yargs@17.7.2\node_modules\yargs\build\lib\command.js:206)
maybeAsyncResult (c:\zdev\wdio-qunit-service\node_modules\.pnpm\yargs@17.7.2\node_modules\yargs\build\lib\utils\maybe-async-result.js:9)
handleValidationAndGetResult (c:\zdev\wdio-qunit-service\node_modules\.pnpm\yargs@17.7.2\node_modules\yargs\build\lib\command.js:205)
applyMiddlewareAndGetResult (c:\zdev\wdio-qunit-service\node_modules\.pnpm\yargs@17.7.2\node_modules\yargs\build\lib\command.js:245)
runCommand (c:\zdev\wdio-qunit-service\node_modules\.pnpm\yargs@17.7.2\node_modules\yargs\build\lib\command.js:128)
[runYargsParserAndExecuteCommands] (c:\zdev\wdio-qunit-service\node_modules\.pnpm\yargs@17.7.2\node_modules\yargs\build\lib\yargs-factory.js:1386)
parse (c:\zdev\wdio-qunit-service\node_modules\.pnpm\yargs@17.7.2\node_modules\yargs\build\lib\yargs-factory.js:707)
run (c:\zdev\wdio-qunit-service\node_modules\.pnpm\@wdio+cli@9.5.7\node_modules\@wdio\cli\build\index.js:3216)
<anonymous> (c:\zdev\wdio-qunit-service\node_modules\.pnpm\@wdio+cli@9.5.7\node_modules\@wdio\cli\bin\wdio.js:16)


Call stack when the plugin's onPrepare is called:


CustomLauncher.onPrepare (c:\zdev\wdio-qunit-service\src\index.ts:123)
<anonymous> (c:\zdev\wdio-qunit-service\node_modules\.pnpm\@wdio+cli@9.5.7\node_modules\@wdio\cli\build\index.js:1119)
runServiceHook (c:\zdev\wdio-qunit-service\node_modules\.pnpm\@wdio+cli@9.5.7\node_modules\@wdio\cli\build\index.js:1116)
Launcher.run (c:\zdev\wdio-qunit-service\node_modules\.pnpm\@wdio+cli@9.5.7\node_modules\@wdio\cli\build\index.js:2202)
await (Unknown Source:0)
launch (c:\zdev\wdio-qunit-service\node_modules\.pnpm\@wdio+cli@9.5.7\node_modules\@wdio\cli\build\index.js:3109)
handler3 (c:\zdev\wdio-qunit-service\node_modules\.pnpm\@wdio+cli@9.5.7\node_modules\@wdio\cli\build\index.js:3144)
await (Unknown Source:0)
<anonymous> (c:\zdev\wdio-qunit-service\node_modules\.pnpm\yargs@17.7.2\node_modules\yargs\build\lib\command.js:206)
maybeAsyncResult (c:\zdev\wdio-qunit-service\node_modules\.pnpm\yargs@17.7.2\node_modules\yargs\build\lib\utils\maybe-async-result.js:9)
handleValidationAndGetResult (c:\zdev\wdio-qunit-service\node_modules\.pnpm\yargs@17.7.2\node_modules\yargs\build\lib\command.js:205)
applyMiddlewareAndGetResult (c:\zdev\wdio-qunit-service\node_modules\.pnpm\yargs@17.7.2\node_modules\yargs\build\lib\command.js:245)
runCommand (c:\zdev\wdio-qunit-service\node_modules\.pnpm\yargs@17.7.2\node_modules\yargs\build\lib\command.js:128)
[runYargsParserAndExecuteCommands] (c:\zdev\wdio-qunit-service\node_modules\.pnpm\yargs@17.7.2\node_modules\yargs\build\lib\yargs-factory.js:1386)
parse (c:\zdev\wdio-qunit-service\node_modules\.pnpm\yargs@17.7.2\node_modules\yargs\build\lib\yargs-factory.js:707)
run (c:\zdev\wdio-qunit-service\node_modules\.pnpm\@wdio+cli@9.5.7\node_modules\@wdio\cli\build\index.js:3216)
<anonymous> (c:\zdev\wdio-qunit-service\node_modules\.pnpm\@wdio+cli@9.5.7\node_modules\@wdio\cli\bin\wdio.js:16)


Call stack when the message `1 passed, 0 total (0% completed) in 00:00:29` is logged:

WDIOCLInterface.printSummary (c:\zdev\wdio-qunit-service\node_modules\.pnpm\@wdio+cli@9.5.7\node_modules\@wdio\cli\build\index.js:2121)
WDIOCLInterface.finalise (c:\zdev\wdio-qunit-service\node_modules\.pnpm\@wdio+cli@9.5.7\node_modules\@wdio\cli\build\index.js:2135)
Launcher.run (c:\zdev\wdio-qunit-service\node_modules\.pnpm\@wdio+cli@9.5.7\node_modules\@wdio\cli\build\index.js:2209)
process.processTicksAndRejections (<node_internals>/internal/process/task_queues:105)
await (Unknown Source:0)
processTicksAndRejections (<node_internals>/internal/process/task_queues:105)
await (Unknown Source:0)
processTicksAndRejections (<node_internals>/internal/process/task_queues:105)
await (Unknown Source:0)
processTicksAndRejections (<node_internals>/internal/process/task_queues:105)
await (Unknown Source:0)
launch (c:\zdev\wdio-qunit-service\node_modules\.pnpm\@wdio+cli@9.5.7\node_modules\@wdio\cli\build\index.js:3109)
handler3 (c:\zdev\wdio-qunit-service\node_modules\.pnpm\@wdio+cli@9.5.7\node_modules\@wdio\cli\build\index.js:3144)
await (Unknown Source:0)
<anonymous> (c:\zdev\wdio-qunit-service\node_modules\.pnpm\yargs@17.7.2\node_modules\yargs\build\lib\command.js:206)
maybeAsyncResult (c:\zdev\wdio-qunit-service\node_modules\.pnpm\yargs@17.7.2\node_modules\yargs\build\lib\utils\maybe-async-result.js:9)
handleValidationAndGetResult (c:\zdev\wdio-qunit-service\node_modules\.pnpm\yargs@17.7.2\node_modules\yargs\build\lib\command.js:205)
applyMiddlewareAndGetResult (c:\zdev\wdio-qunit-service\node_modules\.pnpm\yargs@17.7.2\node_modules\yargs\build\lib\command.js:245)
runCommand (c:\zdev\wdio-qunit-service\node_modules\.pnpm\yargs@17.7.2\node_modules\yargs\build\lib\command.js:128)
[runYargsParserAndExecuteCommands] (c:\zdev\wdio-qunit-service\node_modules\.pnpm\yargs@17.7.2\node_modules\yargs\build\lib\yargs-factory.js:1386)
parse (c:\zdev\wdio-qunit-service\node_modules\.pnpm\yargs@17.7.2\node_modules\yargs\build\lib\yargs-factory.js:707)
run (c:\zdev\wdio-qunit-service\node_modules\.pnpm\@wdio+cli@9.5.7\node_modules\@wdio\cli\build\index.js:3216)
<anonymous> (c:\zdev\wdio-qunit-service\node_modules\.pnpm\@wdio+cli@9.5.7\node_modules\@wdio\cli\bin\wdio.js:16)

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

No one assigned

    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