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

Tests isolation #2

Open
piranna opened this issue Apr 3, 2022 · 2 comments
Open

Tests isolation #2

piranna opened this issue Apr 3, 2022 · 2 comments

Comments

@piranna
Copy link
Contributor

piranna commented Apr 3, 2022

Instead of using Workers, use cluster module ir child_process. This way, they would be full y independent processes so they would not share global atte, the same way Jest default environment does, and Aldo native chdir can be used.

@nicolo-ribaudo
Copy link
Owner

Workers don't share global state between each other.

Jest gets test isolation by running every test in a new "vm context", using the vm Node.js module. The purpose of this runner is to avoid dong that, which means that we cannot have tests isolation.

(technically, we could spawn a new worker/process for every test: however, that would make the runner painfully slower, probably orders of magnitude slower than the default Jest runner).

@bajtos
Copy link

bajtos commented Apr 13, 2022

(technically, we could spawn a new worker/process for every test: however, that would make the runner painfully slower, probably orders of magnitude slower than the default Jest runner).

How about spawning a new worker process per test file? It would give us partial isolation - the global state is shared by all tests in a single file but not between different test files. The downside is the slightly more complex mental model - a change in the global state affects some tests but not all.

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

3 participants