Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Running subsets of Jest tests in parallel

We're using Jest to power our Node.js tests, these interact with a Postgres database to test CRUD operations. We're currently passing the --runInBand CLI option to ensure our tests operate in serial, this works fine but is obviously slower than we'd like.

Now from reading around (and previous experience) I've found it useful to be able to mark groups of tests as parallelise-able. This is possible with nose in python but I cannot seem to find the syntax in Jest. Is this possible? Or is there another approach to speeding up database (or state constrained to generalise) tests that Jest advocates?

Thanks, Alex

like image 216
Alex Latchford Avatar asked Nov 08 '22 23:11

Alex Latchford


1 Answers

Put your tests in separate files (in a new sub folder if you want to keep them organized). That way Jest runs the files in parallel.

like image 128
trusktr Avatar answered Nov 14 '22 20:11

trusktr