webdriverio-community / wdio-html-reporter

Fork of wdio-html-format-reporter
MIT License
18 stars 27 forks source link

Couldn't initialise "wdio-html-nice-reporter". Error [ERR_REQUIRE_ESM]: require() of ES Module #99

Open randquraan opened 1 year ago

randquraan commented 1 year ago

I'm facing this issue for a week, I tried all the solutions but I keep getting that:

2023-06-09T07:57:14.388Z ERROR @wdio/local-runner: Failed launching test session: Error: Couldn't initialise "wdio-html-nice-reporter". Error [ERR_REQUIRE_ESM]: require() of ES Module/node_modules/@wdio/reporter/build/index.js from /node_modules/wdio-html-nice-reporter/lib/htmlReporter.js not supported. Instead change the require of index.js in /node_modules/wdio-html-nice-reporter/lib/htmlReporter.js to a dynamic import() which is available in all CommonJS modules. at require.extensions. [as .js] (/node_modules/ts-node/dist/index.js:851:20) at Object. (node_modules/wdio-html-nice-reporter/lib/htmlReporter.js:6:36) at require.extensions. [as .js] (/node_modules/ts-node/dist/index.js:851:20) at Object. (/node_modules/wdio-html-nice-reporter/lib/index.js:7:40) at require.extensions. [as .js] (/node_modules/ts-node/dist/index.js:851:20) at safeRequire (//node_modules/@wdio/utils/build/utils.js:189:16) at initialisePlugin (/node_modules/@wdio/utils/build/initialisePlugin.js:37:44) at BaseReporter.initReporter (/node_modules/@wdio/runner/build/reporter.js:154:58) at Array.map () at new BaseReporter (//node_modules/@wdio/runner/build/reporter.js:22:50) at Runner.run (/node_modules/@wdio/runner/build/index.js:78:26) at safeRequire (/node_modules/@wdio/utils/build/utils.js:192:15) at initialisePlugin (/node_modules/@wdio/utils/build/initialisePlugin.js:37:44) at BaseReporter.initReporter (/node_modules/@wdio/runner/build/reporter.js:154:58) at Array.map () at new BaseReporter (/node_modules/@wdio/runner/build/reporter.js:22:50) at Runner.run( /node_modules/@wdio/runner/build/index.js:78:26) at processTicksAndRejections (node:internal/process/task_queues:95:5)

rpii commented 1 year ago

You need to read up on the webdriver io changes to ESM. There are some changes you need to make. you can look at the test code in the reporter to see it.

On Fri, Jun 9, 2023 at 1:03 AM Rand AlQuran @.***> wrote:

I'm facing this issue for a week, I tried all the solutions but I keep getting that:

2023-06-09T07:57:14.388Z ERROR @wdio/local-runner: Failed launching test session: Error: Couldn't initialise "wdio-html-nice-reporter". Error [ERR_REQUIRE_ESM]: require() of ES @./reporter/build/index.js from /node_modules/wdio-html-nice-reporter/lib/htmlReporter.js not supported. Instead change the require of index.js in /node_modules/wdio-html-nice-reporter/lib/htmlReporter.js to a dynamic import() which is available in all CommonJS modules. at require.extensions. [as .js] (/node_modules/ts-node/dist/index.js:851:20) at Object. (node_modules/wdio-html-nice-reporter/lib/htmlReporter.js:6:36) at require.extensions. [as .js] (/node_modules/ts-node/dist/index.js:851:20) at Object. (/node_modules/wdio-html-nice-reporter/lib/index.js:7:40) at require.extensions. [as .js] (/node_modules/ts-node/dist/index.js:851:20) at safeRequire @./utils/build/utils.js:189:16) at initialisePlugin @./utils/build/initialisePlugin.js:37:44) at BaseReporter.initReporter @./runner/build/reporter.js:154:58) at Array.map () at new BaseReporter @./runner/build/reporter.js:22:50) at Runner.run @./runner/build/index.js:78:26) at safeRequire @./utils/build/utils.js:192:15) at initialisePlugin @./utils/build/initialisePlugin.js:37:44) at BaseReporter.initReporter @./runner/build/reporter.js:154:58) at Array.map () at new BaseReporter @./runner/build/reporter.js:22:50) at Runner.run( @.***/runner/build/index.js:78:26) at processTicksAndRejections (node:internal/process/task_queues:95:5)

— Reply to this email directly, view it on GitHub https://github.com/rpii/wdio-html-reporter/issues/99, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEABIEJVVWO3ZCRULPORE53XKLKCXANCNFSM6AAAAAAZAJMP3Q . You are receiving this because you are subscribed to this thread.Message ID: @.***>

vdrulerz commented 1 year ago

@rpii can you please help in sharing the direct file reference or the required changes in the configuration file, many people are struggling to get this reporter working with WDIO V8 so please help in sharing the same.

samuelseverino commented 1 year ago

I facing same issue! any solution?

rpii commented 1 year ago

Webdriver IO v 8 is an esm module. you must use the v8 reporter and convert your test to a module. I have attached a tsconfig file that I have used for my test.

On Fri, Jul 7, 2023 at 12:21 PM samuelseverino @.***> wrote:

I facing same issue! any solution?

— Reply to this email directly, view it on GitHub https://github.com/rpii/wdio-html-reporter/issues/99#issuecomment-1625943858, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEABIEIPJWDOAVJYIGU3ID3XPBOQ3ANCNFSM6AAAAAAZAJMP3Q . You are receiving this because you were mentioned.Message ID: @.***>