webdriverio icon indicating copy to clipboard operation
webdriverio copied to clipboard

[🐛 Bug]: <title> Top-level await is currently not supported Issue

Open siddharthmittal97 opened this issue 1 year ago • 2 comments

Have you read the Contributing Guidelines on issues?

WebdriverIO Version

9.0.6

Node.js Version

20.17.0

Mode

Standalone Mode

Which capabilities are you using?

capabilities: [{
    
        // maxInstances can get overwritten per capability. So if you have an in-house Selenium
        // grid with only 5 firefox instances available you can make sure that not more than
        // 5 instances get started at a time.
        maxInstances: 5,
        //
        browserName: 'chrome',
        acceptInsecureCerts: true,
        "goog:chromeOptions": {
            args: [
              '--headless',
              //"--disk-cache-dir=" + __dirname + "/.cache",
              "--disable-dev-shm-usage",
              "--no-sandbox",
              "disable-notifications",
              "--disable-extensions",
              "--disable-gpu",
              "--window-size=1366,768",
            ],
            excludeSwitches: ["enable-automation"],
            //useAutomationExtension: false,
          },
        // If outputDir is provided WebdriverIO can capture driver session logs
        // it is possible to configure which logTypes to include/exclude.
        // excludeDriverLogs: ['*'], // pass '*' to exclude all driver session logs
        // excludeDriverLogs: ['bugreport', 'server'],
    }],

What happened?

When running command

npx wdio run wdio.conf.js --spec ./features/sample.feature

[0-0] RUNNING in chrome - file:///features/sample.feature [0-0] 2024-08-24T16:49:22.474Z ERROR @wdio/runner: Error: Transform failed with 2 errors: [0-0] /home/testM/node_modules/@wdio/cucumber-framework/node_modules/@wdio/logger/build/index.js:7:11: ERROR: Top-level await is currently not supported with the "cjs" output format [0-0] /home/testM/node_modules/@wdio/cucumber-framework/node_modules/@wdio/logger/build/index.js:13:11: ERROR: Top-level await is currently not supported with the "cjs" output format [0-0] at failureErrorWithLog (/home/testM/node_modules/tsx/node_modules/esbuild/lib/main.js:1476:15) [0-0] at /home/testM/node_modules/tsx/node_modules/esbuild/lib/main.js:755:50 [0-0] at responseCallbacks. (/home/testM/node_modules/tsx/node_modules/esbuild/lib/main.js:622:9) [0-0] at handleIncomingPacket (/home/testM/node_modules/tsx/node_modules/esbuild/lib/main.js:677:12) [0-0] at Socket.readFromStdout (/home/testM/node_modules/tsx/node_modules/esbuild/lib/main.js:600:7) [0-0] at Socket.emit (node:events:519:28) [0-0] at addChunk (node:internal/streams/readable:559:12) [0-0] at readableAddChunkPushByteMode (node:internal/streams/readable:510:3) [0-0] at Readable.push (node:internal/streams/readable:390:5) [0-0] at Pipe.onStreamRead (node:internal/stream_base_commons:191:23) [0-0] Error: Transform failed with 2 errors: /home/testM/node_modules/@wdio/cucumber-framework/node_modules/@wdio/logger/build/index.js:7:11: ERROR: Top-level await is currently not supported with the "cjs" output format /home/testM/node_modules/@wdio/cucumber-framework/node_modules/@wdio/logger/build/index.js:13:11: ERROR: Top-level await is currently not supported with the "cjs" output format [0-0] FAILED in chrome - file:///features/sample.feature 2024-08-24T16:49:22.668Z ERROR @wdio/cli:utils: Error in onCompleteHook: Error: 'options.jsonDir' does not exist. Error: json does not exist. at Object.collectJSONS (/home/testM/node_modules/cucumber-html-reporter/lib/jsonDir.js:14:15) at Object.generate (/home/testM/node_modules/cucumber-html-reporter/lib/reporter.js:570:13) at Object.generateReport [as generate] (/home/testM/node_modules/cucumber-html-reporter/index.js:30:19) at Object.onComplete (/home/testM/wdio.conf.js:250:16) at file:///home/testM/node_modules/@wdio/cli/build/index.js:1258:13 at Array.map () at runOnCompleteHook (file:///home/testM/node_modules/@wdio/cli/build/index.js:1256:37) at Launcher.run (file:///home/testM/node_modules/@wdio/cli/build/index.js:2200:39) at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

What is your expected behavior?

Ideally it should run without giving any error

How to reproduce the bug.

1 Setup webdriverIo 2 Mjust have package.json like this

{ "name": "test", "devDependencies": { "@wdio/cli": "^9.0.7", "@wdio/local-runner": "^9.0.7" }, "scripts": { "wdio": "wdio run ./wdio.conf.js" }, "dependencies": { "@wdio/cucumber-framework": "^8.39.0", "cucumber-html-reporter": "^7.1.1", "fs-extra": "^11.2.0", "properties-parser": "^0.6.0", "wdio-cucumberjs-json-reporter": "^5.2.1" } }

3 Run the test

Relevant log output

[0-0] RUNNING in chrome - file:///features/sample.feature
[0-0] 2024-08-24T16:49:22.474Z ERROR @wdio/runner: Error: Transform failed with 2 errors:
[0-0] /home/testM/node_modules/@wdio/cucumber-framework/node_modules/@wdio/logger/build/index.js:7:11: ERROR: Top-level await is currently not supported with the "cjs" output format
[0-0] /home/testM/node_modules/@wdio/cucumber-framework/node_modules/@wdio/logger/build/index.js:13:11: ERROR: Top-level await is currently not supported with the "cjs" output format
[0-0]     at failureErrorWithLog (/home/testM/node_modules/tsx/node_modules/esbuild/lib/main.js:1476:15)
[0-0]     at /home/testM/node_modules/tsx/node_modules/esbuild/lib/main.js:755:50
[0-0]     at responseCallbacks.<computed> (/home/testM/node_modules/tsx/node_modules/esbuild/lib/main.js:622:9)
[0-0]     at handleIncomingPacket (/home/testM/node_modules/tsx/node_modules/esbuild/lib/main.js:677:12)
[0-0]     at Socket.readFromStdout (/home/testM/node_modules/tsx/node_modules/esbuild/lib/main.js:600:7)
[0-0]     at Socket.emit (node:events:519:28)
[0-0]     at addChunk (node:internal/streams/readable:559:12)
[0-0]     at readableAddChunkPushByteMode (node:internal/streams/readable:510:3)
[0-0]     at Readable.push (node:internal/streams/readable:390:5)
[0-0]     at Pipe.onStreamRead (node:internal/stream_base_commons:191:23)
[0-0]  Error:  Transform failed with 2 errors:
/home/testM/node_modules/@wdio/cucumber-framework/node_modules/@wdio/logger/build/index.js:7:11: ERROR: Top-level await is currently not supported with the "cjs" output format
/home/testM/node_modules/@wdio/cucumber-framework/node_modules/@wdio/logger/build/index.js:13:11: ERROR: Top-level await is currently not supported with the "cjs" output format
[0-0] FAILED in chrome - file:///features/sample.feature
2024-08-24T16:49:22.668Z ERROR @wdio/cli:utils: Error in onCompleteHook: Error: 'options.jsonDir' does not exist. Error: json does not exist.
    at Object.collectJSONS (/home/testM/node_modules/cucumber-html-reporter/lib/jsonDir.js:14:15)
    at Object.generate (/home/testM/node_modules/cucumber-html-reporter/lib/reporter.js:570:13)
    at Object.generateReport [as generate] (/home/testM/node_modules/cucumber-html-reporter/index.js:30:19)
    at Object.onComplete (/home/testM/wdio.conf.js:250:16)
    at file:///home/testM/node_modules/@wdio/cli/build/index.js:1258:13
    at Array.map (<anonymous>)
    at runOnCompleteHook (file:///home/testM/node_modules/@wdio/cli/build/index.js:1256:37)
    at Launcher.run (file:///home/testM/node_modules/@wdio/cli/build/index.js:2200:39)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

Code of Conduct

  • [X] I agree to follow this project's Code of Conduct

Is there an existing issue for this?

  • [X] I have searched the existing issues

siddharthmittal97 avatar Aug 24 '24 16:08 siddharthmittal97

@siddharthmittal97 can you please provide a minimal reproducible example?

christian-bromann avatar Aug 25 '24 16:08 christian-bromann

Thanks for raising this issue 🙏

Unfortunately we can't help you without a reproducible example in this matter. Please read our contributing guidelines on how to create a reproducible example. If you can't provide a reproducible example we will close this issue in 7 days.

If you have any questions please reach out to us on our Discord channel. We are happy to help you out there.

wdio-bot avatar Aug 25 '24 16:08 wdio-bot

If you are using Typescript, make sure that the target supports top level await. My guess is that you are targeting a version that does not support this.

erwinheitzman avatar Aug 29 '24 15:08 erwinheitzman

Hello @christian-bromann @erwinheitzman

I am sharing Minimal Replication Steps

Pre-Requisite v20.17.0

java version "17.0.2" 2022-01-18 LTS

Minimal Steps 1 Create one new folder 2 Run the command npm init wdio@latest ./

3 Then choose the Options -E2E Testing -On my local machine -Web -Chrome -Cucumber -No -Yes -Yes -Yes -spec -wait for -no -no simply enter Then yes on npm install


Now package.json look like this

{ "name": "ReplicateIssue", "type": "module", "devDependencies": { "@wdio/cli": "^9.0.7", "@wdio/cucumber-framework": "^9.0.6", "@wdio/local-runner": "^9.0.7" }, "scripts": { "wdio": "wdio run ./wdio.conf.js" } }


Next thing is to install

npm i wdio-cucumberjs-json-reporter

Now when I try to Install it - I will get one error - I know the solution for it

npm error code ERESOLVE npm error ERESOLVE unable to resolve dependency tree npm error npm error While resolving: ReplicateIssue@undefined npm error Found: @wdio/[email protected] npm error node_modules/@wdio/cucumber-framework npm error dev @wdio/cucumber-framework@"^9.0.6" from the root project npm error npm error Could not resolve dependency: npm error peer @wdio/cucumber-framework@"^8.0.0" from [email protected] npm error node_modules/wdio-cucumberjs-json-reporter npm error wdio-cucumberjs-json-reporter@"*" from the root project npm error npm error Fix the upstream dependency conflict, or retry npm error this command with --force or --legacy-peer-deps npm error to accept an incorrect (and potentially broken) dependency resolution. npm error npm error npm error For a full report see: npm error /home/testmirketaautomation/.npm/_logs/2024-08-29T15_20_56_606Z-eresolve-report.txt npm error A complete log of this run can be found in: /home/testmirketaautomation/.npm/_logs/2024-08-29T15_20_56_606Z-debug-0.log


So I go to node modules & delete wdio/cucumber framework & Install cucumber framework of older version

npm i @wdio/[email protected]


Then I run npm run wdio

I get one more error of chrome

So I in wdio.conf.js

I added capabilities: [{ maxInstances: 5, browserName: 'chrome', acceptInsecureCerts: true, "goog:chromeOptions": { args: [ '--headless' ], }, }, ],


Then I run npm run wdio

I get error as

ERROR @wdio/runner: Error: Transform failed with 2 errors: /home/TestPOC/ReplicateIssue/node_modules/@wdio/cucumber-framework/node_modules/@wdio/logger/build/index.js:7:11: ERROR: Top-level await is currently not supported with the "cjs" output format /home/TestPOC/ReplicateIssue/node_modules/@wdio/cucumber-framework/node_modules/@wdio/logger/build/index.js:13:11: ERROR: Top-level await is currently not supported with the "cjs" output format at failureErrorWithLog (/home/TestPOC/ReplicateIssue/node_modules/esbuild/lib/main.js:1476:15) at /home/TestPOC/ReplicateIssue/node_modules/esbuild/lib/main.js:755:50 at responseCallbacks. (/home/TestPOC/ReplicateIssue/node_modules/esbuild/lib/main.js:622:9) at handleIncomingPacket (/home/TestPOC/ReplicateIssue/node_modules/esbuild/lib/main.js:677:12) at Socket.readFromStdout (/home/TestPOC/ReplicateIssue/node_modules/esbuild/lib/main.js:600:7) at Socket.emit (node:events:519:28) at addChunk (node:internal/streams/readable:559:12) at readableAddChunkPushByteMode (node:internal/streams/readable:510:3) at Readable.push (node:internal/streams/readable:390:5) at Pipe.onStreamRead (node:internal/stream_base_commons:191:23)

Error: Transform failed with 2 errors: /home/TestPOC/ReplicateIssue/node_modules/@wdio/cucumber-framework/node_modules/@wdio/logger/build/index.js:7:11: ERROR: Top-level await is currently not supported with the "cjs" output format /home/TestPOC/ReplicateIssue/node_modules/@wdio/cucumber-framework/node_modules/@wdio/logger/build/index.js:13:11: ERROR: Top-level await is currently not supported with the "cjs" output format

siddharthmittal97 avatar Aug 29 '24 15:08 siddharthmittal97

Thanks for raising this issue 🙏

Unfortunately we can't help you without a reproducible example in this matter. Please read our contributing guidelines on how to create a reproducible example. If you can't provide a reproducible example we will close this issue in 7 days.

If you have any questions please reach out to us on our Discord channel. We are happy to help you out there.

@wdio-bot already updated

siddharthmittal97 avatar Aug 29 '24 18:08 siddharthmittal97

Hello @christian-bromann '

I have added the replication steps . Can you please tell Github Bot that "we have now correct replication steps" , Let this Issue Open

siddharthmittal97 avatar Aug 31 '24 05:08 siddharthmittal97

This seems to be a duplicate of https://github.com/webdriverio-community/wdio-cucumberjs-json-reporter/issues/582, let's close this issue and continue our convo there.

christian-bromann avatar Sep 05 '24 13:09 christian-bromann