-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Description
Have you read the Contributing Guidelines on issues?
- I have read the Contributing Guidelines on issues.
WebdriverIO Version
latest
Node.js Version
20.11.1
Mode
WDIO Testrunner
Which capabilities are you using?
No response
What happened?
Neither the wdio config setting autoCompileOpts.autoCompile, nor the CLI argument --autoCompileOpts.autoCompile=false allow disabling the ts-node loader. Notably, we have ts-node v8 installed as a transitive dependency which does not provide an esm/transpile-only loader entry-point, but which is used by WebdriverIO regardless of any setting.
edit: The wdio config setting autoCompileOpts.autoCompile not preventing ts-loader/babel execution for config parsing is apparently expected (Chicken & egg problem).
What is your expected behavior?
WebdriverIO should work even if there's an older version of ts-node installed; it should then simply not try to use it.
Furthermore, --autoCompileOpts.autoCompile=false should always be respected if it's passed early as a CLI argument, as it is documented in wdio --help.
How to reproduce the bug.
An example project can be seen here. Just install the dependencies with npm and run the three scripts in the package.json:
- The
wdioscript doesn't work, even thoughwdio.conf.jshasautoCompileset tofalse. edit: looks like expected behavior (Chicken & egg problem) - The
wdio-broken-argscript also doesn't work, even though we also explicitly set the argument
--autoCompileOpts.autoCompile=falseas documented inwdio --help. wdio-working-argdoes work, but is undocumented.
1 and 2 throw the same error. I was able to trace the 2nd case to autoCompile being the truthy string "false" instead of a boolean here:
webdriverio/packages/wdio-config/src/node/utils.ts
Lines 59 to 62 in 46a9637
| export async function loadAutoCompilers(autoCompileConfig: Options.AutoCompileConfig, requireService: ModuleImportService) { | |
| if (!autoCompileConfig.autoCompile) { | |
| return | |
| } |
Adding || autoCompileConfig.autoCompile === "false" to this if-condition fixes the 2nd case, but it would be even better to fix both, or to just don't try using ts-node if it's below v9.
Relevant log output
INFO @wdio/cli:launcher: Run onPrepare hook
INFO @wdio/utils: Setting up browser driver for: chrome@stable
INFO @wdio/utils: Setting up browser binaries for: chrome@stable
INFO webdriver: Using Chromedriver v122.0.6261.94 from cache directory /tmp
INFO webdriver: Setting up chrome v122.0.6261.94
INFO @wdio/cli:launcher: Run onWorkerStart hook
INFO @wdio/local-runner: Start worker 0-0 with arg: run,./wdio.conf.js,--autoCompileOpts.autoCompile=false
DEBUG @wdio/local-runner: Send command run to worker with cid "0-0"
[0-0] Error: Cannot find module '${ommitted}/wdio-autoCompile/node_modules/ts-node/esm/transpile-only' imported from ${ommitted}/wdio-autoCompile/
[0-0] at finalizeResolution (node:internal/modules/esm/resolve:264:11)
[0-0] at moduleResolve (node:internal/modules/esm/resolve:917:10)
[0-0] at defaultResolve (node:internal/modules/esm/resolve:1130:11)
[0-0] at nextResolve (node:internal/modules/esm/hooks:865:28)
[0-0] at Hooks.resolve (node:internal/modules/esm/hooks:303:30)
[0-0] at ModuleLoader.resolve (node:internal/modules/esm/loader:358:35)
[0-0] at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:240:38)
[0-0] at ModuleLoader.import (node:internal/modules/esm/loader:328:34)
[0-0] at Hooks.register (node:internal/modules/esm/hooks:164:51)
[0-0] at initializeHooks (node:internal/modules/esm/utils:265:17)
DEBUG @wdio/local-runner: Runner 0-0 finished with exit code 1
[0-0] FAILEDCode 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