Certain tasks like end-to-end (e2e) tests, integration tests, or large unit test suites can be large, monolithic tasks that take a considerable amount of time to execute. As a result, teams often push them to a nightly or even weekly build rather than running them for each PR. This approach is suboptimal as it increases the risk of merging problematic PRs.
Manually splitting these slow tasks can be complex and require ongoing maintenance. Nx Atomizer solves this by automatically generating runnable targets for each test file. For example, a task that takes 10 minutes can be split and distributed as five 2-minute tasks per agent. This allows for:
- parallelization across multiple machines with Workers
- faster flaky test detection & retries by isolating and re-running only the failed tests
Enable automated task splitting
Section titled “Enable automated task splitting”Step 1: Connect to Nx Cloud
Section titled “Step 1: Connect to Nx Cloud”To use automated task splitting, you need to connect your workspace to Nx Cloud (if you haven't already).
npx nx@latest connectConnect from your browserSign in to Nx Cloud and connect your repository without the CLI
For the full pipeline walkthrough, see Setting Up CI.
Step 2: add the appropriate plugin
Section titled “Step 2: add the appropriate plugin”Run this command to set up inferred tasks and enable task splitting for each plugin:
nx add @nx/cypressnx add @nx/playwrightnx add @nx/jestnx add @nx/vitestnx add @nx/gradleThis command will register the appropriate plugin in the plugins array of nx.json.
Update an existing project to use automated task splitting
Section titled “Update an existing project to use automated task splitting”If you are already using the @nx/cypress, @nx/playwright, @nx/jest, @nx/vitest, or @nx/gradle plugin, you need to manually add the appropriate configuration to the plugins array of nx.json. Follow the instructions for the plugin you are using:
- Configure Cypress task splitting
- Configure Playwright task splitting
- Configure Jest task splitting
- Configure Vitest task splitting
- Configure Gradle testing task splitting
Verify automated task splitting works
Section titled “Verify automated task splitting works”Run the following command to open the project detail view for your test project:
nx show project my-project-e2eadmin-e2e
Root: apps/admin-e2e
Type:application
Targets
e2e-ci
nx:noop
Cacheablee2e-ci--src/e2e/app.cy.ts
cypress run --env webServerCommand="nx run admin:serve-static" --spec src/e2e/app.cy.ts
Cacheablee2e-ci--src/e2e/login.cy.ts
cypress run --env webServerCommand="nx run admin:serve-static" --spec src/e2e/login.cy.ts
Cacheable
e2e
cypress run
Cacheablelint
eslint .
Cacheable
If you configured Nx Atomizer properly, you'll see that there are tasks named e2e, e2e-ci (or similar for other test types) and a task for each test file.
During local development, you'll want to continue using the base task (e.g., e2e, test) as it is more efficient on a single machine.
nx e2e my-project-e2eThe -ci variant task truly shines when configured and run on CI.
Configure automated task splitting on CI
Section titled “Configure automated task splitting on CI”Update your CI pipeline to run the -ci variant task (e.g., e2e-ci, test-ci), which will automatically run all the inferred tasks for the individual test files. Distribution and stop conditions come from your .nx/ci-config.yaml file:
dte: distribute-on: 3 linux-medium-jslifecycle: stop-after: - e2e-ciHere's an example of a GitHub Actions workflow:
name: CI# ...jobs: main: runs-on: ubuntu-latest steps: - uses: actions/checkout@v7 with: fetch-depth: 0 filter: tree:0
- uses: pnpm/action-setup@v6 with: version: 9
- run: pnpm dlx nx-cloud start-workers
- uses: actions/setup-node@v6 with: node-version: 24 cache: 'pnpm'
- run: pnpm install --frozen-lockfile - uses: nrwl/nx-set-shas@v5
- run: pnpm exec nx affected -t lint test build e2e-ciLearn more about configuring your CI provider with these workflow examples.
Skip unaffected test files
Section titled “Skip unaffected test files”Splitting an e2e suite lets its test files run in parallel, but by default each task still depends on the whole app, its dependencies, and the e2e project. Even a small change can rerun every test file.
Scoping each test file to the code it tests lets Nx reuse the other files' cached results. For example, a change limited to checkout reruns checkout.spec.ts, while search.spec.ts reuses its cached result. A change to shared code that both tests depend on reruns both.
This means fewer tests to execute on each PR, shorter CI runs, and lower compute costs as your suite grows.
Use @nx-ignore-server-inputs with Ultracache to track the code a test imports, or @nx-depends-on to list the projects it covers. See skip unaffected split e2e tests for examples and setup instructions.