0

I am trying to run npm run test, where part of test is setting an environment variable using cross-env. However, in Cypress testing the environment variable is not actually changed. Thanks for the help!

I am using Windows, with a cross-env version of 5.0.1.

I have tried to set the several environment variable with different combinations, such as SET && and setting it in different places in the command but none have actually changed the environment variable. I also tried installing better-npm-run but it did not help solve this problem.

I am running npm run test, where in test RECAPTCHA_SITE_KEY is an environment variable and start is npm run dev.
test: cross-env RECAPTCHA_SITE_KEY='6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI' start-server-and-test start  http-get://127.0.0.1:8080

Instead of the recaptcha key changing, the original site key is being used instead.

3
  • 1
    Could you include a snippet with your actual npm script? I'm not sure what test: cross-env RECAPTCHA_SITE_KEY... is, it looks like pseudocode. Good tips here on how to create a Minimal, Reproducible Example.
    – Will
    Commented Aug 21, 2019 at 21:54
  • 1
    @WillCain done, I am using npm run test, where test is equal to the script above.
    – tpinto
    Commented Aug 22, 2019 at 15:38
  • Thanks, that helps. That snippet is from package.json? That doesn't look like JSON. I wonder if it's a syntax problem? Should look something like { "scripts" : { "test" : "cross-env RECAPTCHA_SITE_KEY..." ... } ... }.
    – Will
    Commented Aug 23, 2019 at 18:05

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.