Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

299
Views
How do I use Cucumber with my ESM (ECMA Module Loader) Project?

I have a simple project that is basically...

export class Application{
  constructor(...){
    ...
  }
  async run(){
    console.log("I Ran!");
  }
}

I want to run this using Cukes so I follow these steps and get this working (notice the .cjs extension to signify to node it is a cjs file)

// features/basic.feature

Feature: Hello World
  Scenario: Hello World
    Given I start the app
    When it is running
    Then I see the console

// features/support/steps.cjs
const { Given, When, Then } = require("@cucumber/cucumber");

Given("I start the app", function () {
  // TODO: Setup child process
  return
});

When("it is running", function () {
  // TODO: Execute using Worker
  return
});

Then("I see the console", function () {
  // assert.equal(this.variable, number);
  return
});

I would execute this using cucumber-js --require features/support/steps.cjs

But now I want to import Application and run the application in a step. Since I can't import a ESM (.mjs) file using .cjs I am not sure how to do this. I tried creating a .mjs version of the step file but I can't get that working either. I also tried cucumber-js --require-module features/support/steps.mjs but it still didn't work.

How do I use Cukes with an ESM-style project?

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

As far as I know, this is still an issue. There is an experimental version of cukes to work with, which started addressing these issues (cukes version 7.2.0), that you could start using to see if you can address the changes you want to implement.

However, version 8.0.0 is on it's way which has a lot of these issues addressed in particular. The new release is due out in the next few days (fingers crossed).

Here's the link for all the work they have done to date to address the issues you are experiencing: cucumber-js add ESM support (take 2)

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!