--env doesn't work when using globbing/filename expansion in --spec
See original GitHub issueIs 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:
- Created 5 years ago
- Comments:9 (5 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Quote your --spec argument or use equals.
--spec=foo
or--spec 'foo'
Thanks for that info, that’s what I needed to know…
According to isaacs/node-glob#glob-primer this syntax works: