Skip to content

🚀 Feature: Running parallel tests in isolation #4947

Open
@rochdev

Description

Is your feature request related to a problem or a nice-to-have?? Please describe.

Right now mocha --parallel works by using a specific number of workers and running tests in parallel across these workers. This means a single worker ends up running many test suites in the same process. The main reason we wanted to parallelize tests is not for speed but to isolate tests, which is not the case even in parallel.

Describe the solution you'd like

It would be great to have a mode where the tests could be completely isolated so that a new worker is started for every file, thus avoiding side-effects from previous files.

Describe alternatives you've considered

Usually, the alternative is to write code and tests in a way that avoids side-effects so that every test can be run in the same process without issues. However, for our case, we patch and instrument many things that are irreversible, like enabling async_hooks, patching the module system, patching dependencies as they are imported, adding ESM loaders, etc. This makes it basically impossible to avoid side-effects, so our only option is to ensure test isolation.

Additional context

I wasn't able to find a way to do this with the latest version of Mocha, but please let me know if there is already a way to do this.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions