--parallel workers versus --grep filtering under limited CI memory
0 reputation · 23 Jul 2022, 06:29 UTC
The goal is to keep CI test runs fast while staying within a fixed CPU and memory quota for a Mocha suite. Two documented approaches are available: using --parallel to distribute tests across worker processes, and using --grep to select a subset of tests by name pattern.
--parallel can reduce wall-clock time on multi-core runners but raises per-worker memory pressure and does not propagate global before/after hooks across workers. --grep reduces the number of tests executed, but its interaction with --parallel is version-dependent and the combined behavior is not clearly deterministic across platforms. Output ordering with both flags is reported as potentially interleaved, which complicates debugging.
For a design decision under limited CI resources, is the test selection performed by --grep guaranteed to be applied before work is distributed to --parallel workers in Mocha 10.x? Does the combination produce deterministic test ordering and reporting across platforms? How does the lack of global hook propagation affect setups that rely on shared initialization when both flags are used together?