-
Notifications
You must be signed in to change notification settings - Fork 45
Limitations
Description: if the reporter injects its own global variable into the process it is not fully supported. Let's take mocha-allure-reporter as an example. It injects global.allure
variable which is an instance of allure-js-commons
runtime. While this works as expected for mocha
when it runs one process, this becomes tricky for mocha-parallel-tests
.
The problem is related to the multi-process behaviour. In mocha-parallel-tests
reporter instance is created in the master (aka "main") process. It's not created for each of the forked processes which execute the test files. Instead, these processes are using its own reporter which primary task is to provide the test results back to the main process, where these results get merged with the results from other processes.
You could've argued that we can run the tests with a custom reporter in both main and forked processes. We can do this. The issue, however, is that the global variable injected by this custom reporter is different for main and subprocess, e.g. you likely get wrong or misinterpreted result.
Outcome: do not use global variables injected by custom reporters or use mocha
to run your tests.
As it was mentioned before mocha-parallel-tests
extends mocha
in a way which allows running test files in parallel by spawning individual processes per each file. However, right now it's impossible to reuse mocha
CLI: it's a massive monolith and we can't use code from it without copying.
This means that there can be a mocha
CLI option which is not supported by mocha-parallel-tests
. To see the list of supported mocha
CLI options look into this directory. If you're missing one you're welcome to send the PR with support for it.