HeadlinesBriefing favicon HeadlinesBriefing.com

Speed Up Cypress Tests with Affected-Tests-Runner

DEV Community •
×

At TrustLayer, Cypress component tests ballooned to hundreds, pushing CI times over 20 minutes for every pull request. The team solved this by building affected-tests-runner, a tool that runs only tests impacted by code changes. This slashed average runtime from 22 minutes to just 3—an 85% reduction.

The tool works by comparing your branch against main, mapping a dependency graph of imports, and identifying which test files depend on changed code. Instead of running the entire suite, it executes a targeted subset. For larger changes, it can also split those tests into parallel groups for faster CI completion.

While the analysis is file-level—meaning a change in a utility file will flag all importers—it still delivers massive efficiency gains. The tool isn't limited to Cypress; it supports Jest, Vitest, and Mocha. For teams drowning in slow pipelines, this approach offers a practical way to cut wait times without sacrificing test coverage.