Courses / Frontend Testing
14. Keeping tests fast with Jest workers and --runInBand
Jest options and patterns to keep test suites performant during incremental migration.
JavaScript
Keeping tests fast with Jest workers and --runInBand
Options and patterns to control Jest's parallel workers and single-process mode so tests run quickly and reliably during migration.
"I need tests to be fast locally, and sometimes running in parallel makes flaky failures and CPU spikes."
Jest runs tests in parallel by default using worker processes; you can limit or disable workers to reduce CPU, I/O contention, and flakiness during incremental migration. Using --runInBand forces a single process; --maxWorkers limits parallelism.
"I need tests to be fast locally, and sometimes running in parallel makes flaky failures and CPU spikes."
Jest runs tests in parallel by default using worker processes; you can limit or disable workers to reduce CPU, I/O contention, and flakiness during incremental migration. Using --runInBand forces a single process; --maxWorkers limits parallelism.