Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to set environment variables for the process in the AVA config #2112

Closed
sindresorhus opened this issue May 2, 2019 · 9 comments · Fixed by #2126
Closed

Add ability to set environment variables for the process in the AVA config #2112

sindresorhus opened this issue May 2, 2019 · 9 comments · Fixed by #2126
Labels
enhancement new functionality 🎁 Rewarded on Issuehunt This issue has been rewarded on Issuehunt help wanted scope:test-environment

Comments

@sindresorhus
Copy link
Member

sindresorhus commented May 2, 2019

Issuehunt badges

I'd like to see a config property called environmentVariables that lets the user set environment variables that are injected into the test file processes. I have often needed to set some test-only environment variables, but it's not easy to do this in a cross-platform matter.


IssueHunt Summary

alexisfontaine alexisfontaine has been rewarded.

Sponsors (Total: $90.00)

Tips

@vinayakkulkarni

This comment has been minimized.

@sindresorhus

This comment has been minimized.

@issuehunt-oss issuehunt-oss bot added the 💵 Funded on Issuehunt This issue has been funded on Issuehunt label May 9, 2019
@IssueHuntBot
Copy link

@0maxxam0 has funded $10.00 to this issue.


@grnch
Copy link
Contributor

grnch commented May 11, 2019

I've found cross-env to be a great solution for cross-platform environment variables in NPM tasks.

Let's say you have some NPM script like this that works only on Linux or Mac:

NODE_ENV=test ava

All you need to do is just slap cross-env in front and you're good to go:

cross-env NODE_ENV=test ava

Now it works on Windows too.

If you've already tried this and it didn't work for you, could you go into more details about your particular setup/workflow?

@sindresorhus
Copy link
Member Author

@grnch I know about cross-env. It's ok, but the commands quickly get messy with it, especially if you need to quote stuff. Using environment variables for tests is a common use-case and AVA can ship with something better built-in.

@IssueHuntBot
Copy link

@IssueHunt has funded $80.00 to this issue.


@IssueHuntBot
Copy link

@sindresorhus has rewarded $81.00 to @alexisfontaine. See it on IssueHunt

  • 💰 Total deposit: $90.00
  • 🎉 Repository reward(0%): $0.00
  • 🔧 Service fee(10%): $9.00

@DavidWells

This comment has been minimized.

@novemberborn

This comment has been minimized.

@avajs avajs locked as resolved and limited conversation to collaborators Oct 8, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement new functionality 🎁 Rewarded on Issuehunt This issue has been rewarded on Issuehunt help wanted scope:test-environment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants