webdriverio-community/wdio-cucumberjs-json-reporter

node_modules/wdio-cucumberjs-json-reporter/dist/cjs/index.d.ts' is not a module

joao-motork opened this issue · 6 comments

Environment (please complete the following information):

  • **Node.js version: 18.16.0
  • **NPM version: 9.5.1
  • **webdriver.io version: 8.10.0
  • **@wdio/cucumber-framework version: 8.10.0
  • **wdio-cucumberjs-json-reporter version: 5.1.0

Config of webdriver.io and the reporter
export const config = { runner: "local", specs: ["./../src/features/**/*.feature"], exclude: [], maxInstances: 1, capabilities: [], logLevel: "warn", bail: 0, baseUrl: baseUrl, waitforTimeout: 20000, connectionRetryTimeout: 60000, connectionRetryCount: 3, services: [], framework: "cucumber", reporters: [ [ "cucumberjs-json", { jsonFolder: reports.jsonReportFolder, }, ], ], cucumberOpts: { requireModule: ["tsconfig-paths/register.js"], require: ["./src/steps/**/*.ts"], backtrace: true, dryRun: false, failFast: false, format: ["pretty"], colors: true, snippets: false, source: false, profile: [], strict: true, tagExpression: "", timeout: 60000, ignoreUndefinedDefinitions: false, }, autoCompileOpts: {autoCompile: true, tsNodeOpts: { transpileOnly: false, project: "tsconfig.json", files: true, }, }, ...hooks, };

Describe the bug
I updated my automation project from wdio v7 to wdio v8. Everything works fine except the wdio-cucumberjs-json-reporter package.

After the update, I got this error:
image

image

This is my tsconfig file:
{ "compilerOptions": { "target": "ES2022", "module": "CommonJS", "moduleResolution": "node", "noImplicitAny": true, "strict": true, "noEmit": true, "removeComments": true, "esModuleInterop": true, "skipLibCheck": true, "forceConsistentCasingInFileNames": true, "pretty": true, "allowSyntheticDefaultImports": true, "resolveJsonModule": true, "types": [ "node", "expect-webdriverio", "@wdio/globals/types", "@wdio/cucumber-framework" ], "baseUrl": ".", "paths": { "@base/*": [ "src/support/pages/@base/*" ], "pages/*": [ "src/support/pages/*" ] } }, "include": [ "./src/**/*.ts" ], "compileOnSave": false, "typeAcquisition": { "enable": false } }

Just pushed a fix and released it. Thanks for reporting.

Hi @christian-bromann

Thanks.
However, I think it is not completely fixed, because the methods are not found:

image

image

@joao-motork can you provide a minimal reproducible example?

I am attaching the full project here:
boilerplate.zip

you can find the call to the "attach" method in the hooks.ts (src/support/hooks.ts)

You were importing it wrong:

- import cucumberJson from "wdio-cucumberjs-json-reporter/dist/utils";
+ import cucumberJson from "wdio-cucumberjs-json-reporter";

Hi @christian-bromann
When I created the zip file of the project I forgot to revert that last minute change (some random trials that I was doing).
Anyway, I've just updated wdio-cucumberjs-json-reporter to version 5.1.2 and it seems to work now.
Thanks