-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
run Mocha's tests concurrently #2839
Comments
We run integration tests, unit tests with Mocha and it takes up to 36 mins to finish all the tests, Which is primarily an issue with how the tests were written in the first place, discrete, and repeating the same operations in different tests |
This is harder to implement than it sounds, because of features that you will want to add once the basics are hooked up. I have this shell script utility that runs shell commands in parallel, waits for all to exit, and exits with code 0 only if all subshells exit with 0 |
We are interested in this feature for LoopBack too. Our main development is happening in https://github.com/strongloop/loopback-next, a medium-sized monorepo. Few comments from the experiments I did so far using https://www.npmjs.com/package/mocha-parallel-tests:
For Mocha and loopback-next, it would be ideal if the same child process could be re-used to run multiple test files. For example, the "master" process can spawn multiple child processes and then fan out test files to run to children one-by-one. When a child finishes running a test file, it can signal the results to master and master can send it another file to run. By re-using child processes this way, I think there will be less (if any) need to switch from child processes to worker threads, because there will be a fixed & small number of child processes to spawn at the beginning. A more complex problem is how to deal with global before/after hooks. Some global hooks are initializing in-memory artifacts, those need to be executed once in each child process. Other global hooks may be touching global state (e.g. resetting & seeding up the test database), we may need to run them only once per test run. |
Seeing there are efforts being put into this I'd like to submit a slightly different use-case. I am using mocha to execute browser automated tests (using This use case does not need other background threads to execute tests concurrently, as most of the time spent in tests is waiting for the browser to do an action. If concurrent execution is added to mocha it would be great to have a way to execute tests concurrently but on a single process. |
I don't see why we couldn't leverage something like concurrently to run our Node.js-based tests concurrently, since we have to invoke Mocha many different times for each type of test.
The text was updated successfully, but these errors were encountered: