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 doesn't work when using globbing/filename expansion in --spec

See original GitHub issue

Is this a Feature or Bug?

Bug

Current behavior:

cypress run --env foo=bar --spec=cypress/integration/**/*.js

does not add foo to the environment variables (cy.env('foo') returns undefined). It works though if I don’t use globs in the spec path.

Desired behavior:

I want to be able to use globbing/filename expansion in the --spec argument and also pass in an environment variable using --env.

Use case: I’m running the same tests on two different projects (using data-cy props) that implement basically the same thing, but one has additional routes. (Yes, I know this is painful to maintain, but it’s a three year old codebase and tests are the first step to start refactoring).

Workaround:

This works:

CYPRESS_foo=bar cypress run --spec=cypress/integration/**/*.js

I’m ok with that workaround but thought I’d leave this here FYI.

Versions

cypress@2.1.0, latest Chrome, macOS 10.13.4

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
brian-manncommented, Jun 5, 2018

Quote your --spec argument or use equals.

--spec=foo or --spec 'foo'

0reactions
simonhaenischcommented, Jun 5, 2018

Thanks for that info, that’s what I needed to know…

According to isaacs/node-glob#glob-primer this syntax works:

--env foo=bar --spec='cypress/integration/@(dir1|dir2)/**/*.js'
Read more comments on GitHub >

github_iconTop Results From Across the Web

Fix unexpected behavior when passing glob pattern for specs
Passing --spec= will interfere with tab-completion of spec names. ... --env doesn't work when using globbing/filename expansion in --spec # ...
Read more >
expand file names that have environment variables in their path
I see that wxWidgets has a wxExpandEnvVars function. I can't use wxWidgets in this case, so I was hoping to find a boost::filesystem...
Read more >
ZSH expanded variables in [[ ... ]] do not perform globbing
I have actually set "globsubst" in .zshrc file so it works without ~, however it is nice to know there is ~ option...
Read more >
Bash Reference Manual - GNU.org
Performs the various shell expansions (see Shell Expansions), breaking the expanded tokens into lists of filenames (see Filename Expansion) ...
Read more >
14 Expansion - zsh
The following f, F, w and W modifiers work only with parameter expansion and filename generation. They are listed here to provide a...
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