Skip to content

[🐛 Bug]: Disabling autoCompileConfig.autoCompile does not work (ts-node v8) #12434

@johnp

Description

@johnp

Have you 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:

  1. The wdio script doesn't work, even though wdio.conf.js has autoCompile set to false. edit: looks like expected behavior (Chicken & egg problem)
  2. The wdio-broken-arg script also doesn't work, even though we also explicitly set the argument
    --autoCompileOpts.autoCompile=false as documented in wdio --help.
  3. wdio-working-arg does 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:

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] FAILED

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