question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ENV variables not being set either in config file or using --env flag in cli

See original GitHub issue

Hi there,

I’m having trouble with environment variables, seems like adding them in cypress.config.js or using --env cli does not register them in cypress. When I inspect the settings in the UI or print the env vars during tests I see the following.

Screenshot 2022-10-07 at 09 41 53

If I use cypress.env.json, it registers my variables but it also shows the same error.

Screenshot 2022-10-07 at 09 47 45

Versions

  • Cypress version: 10.9.0
  • Preprocessor version: 13.0.2
  • Node version: 18.9.1

my cypress.config.js file looks like this:

const { defineConfig } = require("cypress");
const createBundler = require("@bahmutov/cypress-esbuild-preprocessor");
const addCucumberPreprocessorPlugin =
  require("@badeball/cypress-cucumber-preprocessor").addCucumberPreprocessorPlugin;
const createEsbuildPlugin =
  require("@badeball/cypress-cucumber-preprocessor/esbuild").createEsbuildPlugin;

require('dotenv').config({path: './.env'});

module.exports = defineConfig({
 
  e2e: {
    async setupNodeEvents(on, config) {
      const bundler = createBundler({
        plugins: [createEsbuildPlugin(config)],
      });

      on("file:preprocessor", bundler);
      await addCucumberPreprocessorPlugin(on, config);

      return config;
    },

    specPattern: "cypress/e2e/features/*.feature",
    chromeWebSecurity: false,
  },

});

my package.json contains the following:

  "cypress-cucumber-preprocessor": {
    "stepDefinitions": "./cypress/e2e/step_definitions/*.cy.js"
  }

Checklist

  • I’ve read the FAQ.
  • I’ve read Instructions for logging issues.
  • I’m not using cypress-cucumber-preprocessor@4.3.1 (package name has changed and it is no longer the most recent version, see #689).

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
badeballcommented, Oct 9, 2022

It’s not an error, but something set by the plugin and not something you need to be concerned about.

0reactions
mazza1892commented, Oct 9, 2022

Great! so that works, but still seeing the error message too. Any idea what that is?

Screenshot 2022-10-09 at 10 30 57
Read more comments on GitHub >

github_iconTop Results From Across the Web

SAM deploy doesn't set environment variables #1163 - GitHub
I get "unable to use container host config override file from '$HOME/.config/aws-sam-local/container-config.json': HOME env variable is not set" ...
Read more >
Don't use environment variables for configuration | Hacker News
So either a file that's outside of version control with variables you set per environment or actual server environment variables.
Read more >
Setting environment variable in react-native? - Stack Overflow
Works for me in v0. 56. You have to clear bundler's cache by running react-native start --reset-cache every time you change the environment...
Read more >
Pass Docker Environment Variables During The Image Build
Looking for a way to set pass environment variables during your Docker image build ... the image build with --build-arg , but there...
Read more >
Environment variables to configure the AWS CLI
The AWS CLI supports the following environment variables. Specifies an AWS access key associated with an IAM user or role. If defined, this...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found