Open AndyLysenko opened 1 year ago
Thanks for the detailed analysis. I will look into upgrading this.
Rich
On Fri, Dec 30, 2022 at 6:45 AM Andrii Lysenko @.***> wrote:
On 2022-12-01 version 8 of WebdriverIO was released. One of the braking changes https://github.com/webdriverio/webdriverio/blob/main/CHANGELOG.md#v800-2022-12-01 is Transition code base from CommonJS to ESM It means all modules of wdio 8 are now fully ESM and use ESM exports. wdio-html-reporter still uses require() imports, which causes problem as far as I understand.
Steps to reproduce:
- Create a fresh wdio v8 project, with all defaults. npm init wdio .
- Install latest html reporter npm i wdio-html-nice-reporter --save-dev
- Add reporter to wdio config. reporters: ['spec', 'html-nice']
- Import from 'wdio-html-nice-reporter' import {ReportAggregator} from 'wdio-html-nice-reporter';
- Run sample test npm run wdio
Fragment of wdio.conf.ts:
import type { Options } from @.***/types' import {ReportAggregator} from 'wdio-html-nice-reporter';
export const config: Options.Testrunner = {
runner: 'local', autoCompileOpts: { tsNodeOpts: { project: './tsconfig.json' } }, specs: [ './test/specs/**/*.ts' ], reporters: ['html-nice'],
Result:
[0-0] 2022-12-30T13:17:04.411Z ERROR @wdio/local-runner: Failed launching test session: Error: Couldn't initialise "wdio-html-nice-reporter". [0-0] Error [ERR_REQUIRE_ESM]: require() of ES Module @.\reporter\build\index.js from
\node_modules\wdio-html-nice-reporter\lib\htmlReporter.js not supported. [0-0] Instead change the require of index.js in @./utils/build/utils.js:210:15) [0-0] at async initialisePlugin @./utils/build/initialisePlugin.js:32:20) [0-0] at async BaseReporter.initReporters @./runner/build/reporter.js:23:27) [0-0] at async Runner.run @.***/runner/build/index.js:68:9) [0-0] FAILED\node_modules\wdio-html-nice-reporter\lib\htmlReporter.js to a dynamic import() which is available in all CommonJS modules. [0-0] at require.extensions. [as .js] ( \node_modules\ts-node\dist\index.js:851:20) [0-0] at Object. ( \node_modules\wdio-html-nice-reporter\lib\htmlReporter.js:6:36) [0-0] at require.extensions. [as .js] ( \node_modules\ts-node\dist\index.js:851:20) [0-0] at Object. ( \node_modules\wdio-html-nice-reporter\lib\index.js:7:40) [0-0] at require.extensions. [as .js] ( \node_modules\ts-node\dist\index.js:851:20) [0-0] at safeImport What happens as I understand: Test project (which is ESM module) imports 'wdio-html-nice-reporter' (which is CommonJS), that is fine. 'wdio-html-nice-reporter' tries to import @wdio https://github.com/wdio\reporter (which is ESM module) in CommonJS way (require() ). This makes execution failed.
package.json:
{ "name": "my-new-project", "type": "module", "devDependencies": { @./cli": "^8.0.15", @./local-runner": "^8.0.15", @./mocha-framework": "^8.0.14", @./spec-reporter": "^8.0.14", "i": "^0.3.7", "npm": "^9.2.0", "ts-node": "^10.9.1", "typescript": "^4.9.4", "wdio-html-nice-reporter": "^8.0.6", "wdio-wait-for": "^3.0.1" }, "scripts": { "wdio": "wdio run ./wdio.conf.ts" } }
node v19.2.0 npm v 9.2.0
Latest version of 'wdio-html-nice-reporter' 8.0.6 was released a month before wdio 8. To support wdio v8, 'wdio-html-nice-reporter' also has to become fully ESM.
— Reply to this email directly, view it on GitHub https://github.com/rpii/wdio-html-reporter/issues/92, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEABIEIZN7JSJTYV6Y5UFSDWP3YKJANCNFSM6AAAAAATM57TEM . You are receiving this because you are subscribed to this thread.Message ID: @.***>
I have a beta version 8.1.0-beta2 posted in NPM that should work for you. Please try it and let me know
Rich
On Fri, Dec 30, 2022 at 9:32 AM Rich Peters @.***> wrote:
Thanks for the detailed analysis. I will look into upgrading this.
Rich
On Fri, Dec 30, 2022 at 6:45 AM Andrii Lysenko @.***> wrote:
On 2022-12-01 version 8 of WebdriverIO was released. One of the braking changes https://github.com/webdriverio/webdriverio/blob/main/CHANGELOG.md#v800-2022-12-01 is Transition code base from CommonJS to ESM It means all modules of wdio 8 are now fully ESM and use ESM exports. wdio-html-reporter still uses require() imports, which causes problem as far as I understand.
Steps to reproduce:
- Create a fresh wdio v8 project, with all defaults. npm init wdio .
- Install latest html reporter npm i wdio-html-nice-reporter --save-dev
- Add reporter to wdio config. reporters: ['spec', 'html-nice']
- Import from 'wdio-html-nice-reporter' import {ReportAggregator} from 'wdio-html-nice-reporter';
- Run sample test npm run wdio
Fragment of wdio.conf.ts:
import type { Options } from @.***/types' import {ReportAggregator} from 'wdio-html-nice-reporter';
export const config: Options.Testrunner = {
runner: 'local', autoCompileOpts: { tsNodeOpts: { project: './tsconfig.json' } }, specs: [ './test/specs/**/*.ts' ], reporters: ['html-nice'],
Result:
[0-0] 2022-12-30T13:17:04.411Z ERROR @wdio/local-runner: Failed launching test session: Error: Couldn't initialise "wdio-html-nice-reporter". [0-0] Error [ERR_REQUIRE_ESM]: require() of ES Module @.\reporter\build\index.js from
\node_modules\wdio-html-nice-reporter\lib\htmlReporter.js not supported. [0-0] Instead change the require of index.js in @./utils/build/utils.js:210:15) [0-0] at async initialisePlugin @./utils/build/initialisePlugin.js:32:20) [0-0] at async BaseReporter.initReporters @./runner/build/reporter.js:23:27) [0-0] at async Runner.run @.***/runner/build/index.js:68:9) [0-0] FAILED\node_modules\wdio-html-nice-reporter\lib\htmlReporter.js to a dynamic import() which is available in all CommonJS modules. [0-0] at require.extensions. [as .js] ( \node_modules\ts-node\dist\index.js:851:20) [0-0] at Object. ( \node_modules\wdio-html-nice-reporter\lib\htmlReporter.js:6:36) [0-0] at require.extensions. [as .js] ( \node_modules\ts-node\dist\index.js:851:20) [0-0] at Object. ( \node_modules\wdio-html-nice-reporter\lib\index.js:7:40) [0-0] at require.extensions. [as .js] ( \node_modules\ts-node\dist\index.js:851:20) [0-0] at safeImport What happens as I understand: Test project (which is ESM module) imports 'wdio-html-nice-reporter' (which is CommonJS), that is fine. 'wdio-html-nice-reporter' tries to import @wdio https://github.com/wdio\reporter (which is ESM module) in CommonJS way (require() ). This makes execution failed.
package.json:
{ "name": "my-new-project", "type": "module", "devDependencies": { @./cli": "^8.0.15", @./local-runner": "^8.0.15", @./mocha-framework": "^8.0.14", @./spec-reporter": "^8.0.14", "i": "^0.3.7", "npm": "^9.2.0", "ts-node": "^10.9.1", "typescript": "^4.9.4", "wdio-html-nice-reporter": "^8.0.6", "wdio-wait-for": "^3.0.1" }, "scripts": { "wdio": "wdio run ./wdio.conf.ts" } }
node v19.2.0 npm v 9.2.0
Latest version of 'wdio-html-nice-reporter' 8.0.6 was released a month before wdio 8. To support wdio v8, 'wdio-html-nice-reporter' also has to become fully ESM.
— Reply to this email directly, view it on GitHub https://github.com/rpii/wdio-html-reporter/issues/92, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEABIEIZN7JSJTYV6Y5UFSDWP3YKJANCNFSM6AAAAAATM57TEM . You are receiving this because you are subscribed to this thread.Message ID: @.***>
@rpii 8.1.0-beta2 fixed the issue thanks
I still get the same error even with the beta release when I try to I import and create a new ReportAggregator
I still get the same error even with the beta release when I try to I import and create a new ReportAggregator
Can confirm I have the same issue, is there a workaround for this?
After upgrading the version I am facing the issue: https://github.com/rpii/wdio-html-reporter/issues/100. Anyone has any workaround?
StackTrace:
2023-08-03T08:36:21.912Z ERROR @wdio/config:ConfigParser: Failed loading configuration file: file:///Users/aaggarwal/Documents/Sumo-Repo/sumo-ui-test/UIE2ETests/wdio.conf.ts: ReportEvents is not a constructor TypeError: ReportEvents is not a constructor at file:///Users/aaggarwal/Documents/Sumo-Repo/sumo-ui-test/UIE2ETests/node_modules/wdio-html-nice-reporter/lib/htmlReporter.js:10:19 at ModuleJob.run (node:internal/modules/esm/module_job:192:25) at async CustomizedModuleLoader.import (node:internal/modules/esm/loader:228:24) at async ConfigParser.addConfigFile (file:///Users/aaggarwal/Documents/Sumo-Repo/sumo-ui-test/UIE2ETests/node_modules/@wdio/config/build/lib/ConfigParser.js:85:36) at async ConfigParser.initialize (file:///Users/aaggarwal/Documents/Sumo-Repo/sumo-ui-test/UIE2ETests/node_modules/@wdio/config/build/lib/ConfigParser.js:47:13) at async Launcher.run (file:///Users/aaggarwal/Documents/Sumo-Repo/sumo-ui-test/UIE2ETests/node_modules/@wdio/cli/build/launcher.js:37:9)
On 2022-12-01 version 8 of WebdriverIO was released. One of the braking changes is Transition code base from CommonJS to ESM It means all modules of wdio 8 are now fully ESM and use ESM exports. wdio-html-reporter still uses require() imports, which causes problem as far as I understand.
Steps to reproduce:
npm init wdio .
npm i wdio-html-nice-reporter --save-dev
reporters: ['spec', 'html-nice']
import {ReportAggregator} from 'wdio-html-nice-reporter';
npm run wdio
Fragment of wdio.conf.ts:
Result:
What happens as I understand: Test project (which is ESM module) imports 'wdio-html-nice-reporter' (which is CommonJS), that is fine. 'wdio-html-nice-reporter' tries to import @wdio\reporter (which is ESM module) in CommonJS way (require() ). This makes execution failed.
package.json:
node v19.2.0 npm v 9.2.0
Latest version of 'wdio-html-nice-reporter' 8.0.6 was released a month before wdio 8. To support wdio v8, 'wdio-html-nice-reporter' also has to become fully ESM.