How to run Jest tests faster in GitHub Actions
Blog post from Blacksmith
Jest test suites can often be accelerated substantially in GitHub Actions through vertical scaling with more CPU cores or horizontal scaling with test sharding. In a benchmark, a test suite took about 18–19 minutes on a 2-vCPU runner, 9 minutes 37 seconds on 4 vCPUs, 5 minutes 31 seconds on 8 vCPUs, and 3 minutes 34 seconds on 16 vCPUs, though larger machines may face diminishing returns from shared I/O and memory constraints. Splitting the suite into eight Jest shards running simultaneously on separate 2-vCPU runners reduced the longest shard’s duration to 2 minutes 44 seconds, outperforming the 16-vCPU configuration while costing $0.096 compared with $0.128 for the larger runner and $0.076 for the original 2-vCPU run. Sharding is most effective when test execution time greatly exceeds repeated setup time, such as dependency installation, and workflows can use fail-fast behavior to cancel remaining shards after a failure and limit unnecessary costs.
No tracked trend matches for this post yet.
Use this post, company, and trend context to find content marketing opportunities, perform competitive analysis, or address product feature gaps via the Plushcap MCP server or the Plushcap API.