Skip to content

CodeceptJS 4.x - Declaring custom modules still requires all commonJS export #5360

@nlespiaucq

Description

@nlespiaucq

🚩 [4.0.1-beta.23]

For specific needs (ex: to deal with browserstack or to retrieve additional logs), we created some custom plugins / listeners in our solution, following this documentation: https://codecept.io/hooks/#plugins

Example in version 3.x

import CodeceptJS from "codeceptjs";

const traceStep = (): void => {
  CodeceptJS.event.dispatcher.on(CodeceptJS.event.bddStep.before, (step) => {
    console.log(`${step.keyword}${step.text} from ${step.match}`);
  });
};

export = traceStep;

When trying to migrate to 4.x, the only way I found to make it work is to switch to module.export (from commonJS).
https://github.com/nlespiaucq/examples-ts/blob/4.x-plugin/trace.plugin.ts#L9
Note: keeping as-in is not an option as it causes both errors in the IDE and the PR checks (npx tsc --noEmit --skipLibCheck).
Is there another way to handle it? May it be a trouble on long-run?

How to reproduce:

  • Clone: git clone git@github.com:nlespiaucq/examples-ts.git
  • Checkout the 4.x branch: git checkout 4.x-plugin
  • Install everything
cd codeceptjs-examples-ts
npm install
npx playwright install
  • Go to trace.plugin.ts

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions