Skip to content

Add a way to run each test in an isolated environment #1971

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

Closed
gajus opened this issue Oct 29, 2018 · 1 comment
Closed

Add a way to run each test in an isolated environment #1971

gajus opened this issue Oct 29, 2018 · 1 comment

Comments

@gajus
Copy link

gajus commented Oct 29, 2018

Current documentation says that each test file is run in a separate Node.js process:

## Process isolation
Each test file is run in a separate Node.js process. This allows you to change the global state or overriding a built-in in one test file, without affecting another. It's also great for performance on modern multi-core processors, allowing multiple test files to execute in parallel.

AVA will set process.env.NODE_ENV to test, unless the NODE_ENV environment variable has been set. This is useful if the code you're testing has test defaults (for example when picking what database to connect to, or environment-specific Babel options). It may cause your code or its dependencies to behave differently though. Note that 'NODE_ENV' in process.env will always be true.

However, this implies that there is no isolation between tests in the same file.

This affects use of mocking modules such as nock that modify the global http.request.

I suggest adding an option for test-level isolation.

@gajus
Copy link
Author

gajus commented Oct 29, 2018

Just noticed:

#421

@gajus gajus closed this as completed Oct 29, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant