Add support for Test / envVars
See original GitHub issueThis may be out of scope for an issue, as there may be a workaround that I’m not aware of.
I want to set environment variables in tests:
Test / envVars := Map(
"MY_TEST" -> "true",
)
Which are then accessible via:
global.process.env.selectDynamic("MY_TEST").asInstanceOf[js.UndefOr[String]]
For the JVM this works in tandem with Test / fork := true
, however it seems that this is an option that is banned on top of Scala.js:
[error] `test / test` tasks in a Scala.js project require `test / fork := false`.
I’m guessing this happens because Scala.js has to fork a process anyway, but it appears that the forking ignores the envVars
setting. Would be great if it didn’t.
Issue Analytics
- State:
- Created a year ago
- Comments:12 (12 by maintainers)
Top Results From Across the Web
Testing and Environment Variables - Thoughtbot
Learn how to test code using data in environment variables with Climate Control.
Read more >How to test code dependent on environment variables using ...
We can set Environment Variables or System Properties through Maven POM file which I think best way to do Unit Testing for Maven...
Read more >How to use environment variables in test scripts via the API?
You can use environment variables to: Decide which URL to use (when launching tests on heroku machines for example); Pick specific room id's...
Read more >Can't access ENV vars defined in .env.test #16270 - GitHub
I have added an .env.test file to an app based on the environment variable starter, containing one variable TEST_ENV_VARIABLE.
Read more >Dealing with Environment Variables while running Unit Tests
When you create a unit test, you are creating the first consumer of the code under development Environment variables in Cloud Functions is...
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
I have started on this, but likely will not have time any time soon. So feel free to take it over.
@gzm0 Do you still want to do the sbt plugin side of this feature, now that the JSEnv side is done? Or would you prefer that I do it?
I still have a PR to actually (finally) separate the javalib in its own jar in progress, but otherwise I think we’ll be done for 1.11.0.