Skip to content

Support for Node.js Built-in .env File #2346

Open
@x80486

Description

@x80486

🤔 What's the problem you're trying to solve?

Currently, Cucumber.js primarily relies on environment variables set externally for configuration. With Node.js introducing support for the .env file format, it would be beneficial to allow Cucumber.js to read environment variables from the .env file as an additional or alternative source of configuration.

Why This Is Important:

  1. Consistency with Node.js Ecosystem: Given that Node.js supports .env files, adding support for them in Cucumber.js would align with best practices and the Node.js ecosystem's standards.

  2. Enhanced Integration: Cucumber.js could offer seamless integration with Node.js projects by providing built-in support for .env files, fostering a more cohesive testing experience.

✨ What's your proposed solution?

Since this is usually used when developing locally, I think a configuration key might be useful to enable this at the profile level, but there is also simplicity on just enabling this globally or not, in the same way Node.js currently does.

const common = {
  failFast: true,
  parallel: 1,
  require: ["step-definitions/**/*.ts", "support/**/*.ts"],
  requireModule: ["ts-node/register", "tsconfig-paths/register"],
  retry: 1,
};

module.exports = {
  ci: {
    ...common,
    format: [
      "progress"
    ]
  },
  default: {
    ...common,
    env_file: ".env" // <- This is what I meant by a "configuration key"
    format: [
      "progress-bar"
    ]
  }
};

⛏ Have you considered any alternatives or workarounds?

I'm currently using some of the libraries that provide similar behavior.

📚 Any additional context?

N/A

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions