惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

博客园 - Franky
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
美团技术团队
The Cloudflare Blog
量子位
酷 壳 – CoolShell
酷 壳 – CoolShell
博客园_首页
F
Fortinet All Blogs
J
Java Code Geeks
人人都是产品经理
人人都是产品经理
N
Netflix TechBlog - Medium
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
爱范儿
爱范儿
Apple Machine Learning Research
Apple Machine Learning Research
B
Blog RSS Feed
博客园 - 聂微东
Hugging Face - Blog
Hugging Face - Blog
WordPress大学
WordPress大学
小众软件
小众软件
Y
Y Combinator Blog
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Vercel News
Vercel News
S
SegmentFault 最新的问题
有赞技术团队
有赞技术团队

Nx Blog

Sharing Tailwind CSS Styles Across Apps in a Monorepo | Nx Blog How SiriusXM Stays Competitive by Iterating and Getting to Market Fast | Nx Blog Agentic Experience Is the New Developer Experience | Nx Blog Nx Joins the Linux Foundation and the Agentic AI Foundation | Nx Blog A Monorepo Is NOT a Monolith | Nx Blog Why we deleted (most of) our MCP tools | Nx Blog Teach Your AI Agent How to Work in a Monorepo | Nx Blog How Broadcom stays efficient and nimble with monorepos | Nx Blog Why Monorepos are King in the Age of AI | Nx Blog Nx 2026 Roadmap: Expanding Agent Autonomy, Improving Performance, Better Polyglot and More | Nx Blog End to End Autonomous AI Agent Workflows with Nx | Nx Blog Autonomous Agents at Scale | Nx Blog Scaling 700+ Projects: How Nx Became a 'No-Brainer' for Caseware | Nx Blog Configure Tailwind v4 with Angular in an Nx Monorepo | Nx Blog The Missing Multiplier for AI Agent Productivity | Nx Blog A Year of Nx Webinars | Nx Blog Wrapping Up 2025 | Nx Blog Nx 22.3 Release: Angular 21 Support, tsgo Compiler, and Prettier v3 | Nx Blog Nx Cloud Release: Agent Resource Usage | Nx Blog Nx Platform Outperforms DIY Cache by 5x | Nx Blog An Nx Carol: Past, Present, and Future of Your Monorepo | Nx Blog Nx 22.1 Release: Terminal UI on Windows, Storybook 10, Vitest 4, and more! | Nx Blog The Compounding Effect: How Nx Features Multiply Performance Gains | Nx Blog 10 Monorepo Myths Debunked: Separating Fact from Fiction | Nx Blog Nx Cloud Release: Enterprise Task Analytics | Nx Blog Watch and Rebuild Storybook Dependencies with Nx | Nx Blog Book - React for Enterprise: Timeless Architecture for Enterprise Apps | Nx Blog Beyond Remote Cache: Unlock 70% More CI Performance | Nx Blog Nx 22 Release: Expanding the build platform | Nx Blog What's the Point of Generating All This Code If You Can't Merge It? | Nx Blog
3 Test Splitting Techniques that Cut E2E Times up to 90% ...
Miroslav Jonaš · 2025-04-24 · via Nx Blog

"There's nothing worse than waiting for a build to complete, or those e2e tests to run. With Nx Cloud, our development team has saved over 104 hours, almost cutting our build times in half. The installation is seamless and the results are immediate. It's nice to have a tool that passively saves so much development time." - Director of Software Development, enterprise digital marketing firm

One of the most impactful core features of Nx is the affected graph. The affected graph helps us to skip unnecessary work and focus only on the things that have been changed, speeding up our CI and helping us ship features and hotfixes faster.

However, long-running tasks, especially End-to-End (E2E) tests, can become a significant bottleneck and prevent getting the code changes out faster. This is particularly true for monolithic projects, but also in cases when there is a single large E2E project that covers the entire scope of the application. In these scenarios, the full benefits of an affected graph cannot be realized.

In this guide, we'll explore three techniques to speed up your CI by splitting these lengthy test tasks.

Built-in Test Sharding

One of the simplest ways to split long-running tests is by using built-in test sharding features available in popular testing frameworks like Jest and Playwright. These tools allow you to divide your test suite into multiple shards that can be executed in parallel, reducing the perceived test execution time.

In Jest we can utilize the new --shard option to split your test suite. The example below shows splitting into 4 shards.

nx affected -t test -- --shard=1/4
nx affected -t test -- --shard=2/4
nx affected -t test -- --shard=3/4
nx affected -t test -- --shard=4/4

Playwright also supports the --shard option:

nx affected -t e2e -- --shard=1/4
nx affected -t e2e -- --shard=2/4
nx affected -t e2e -- --shard=3/4
nx affected -t e2e -- --shard=4/4

Now that we have our tests sharded, we can distribute the test load and achieve faster feedback. But what about the test runners that don't support sharding?

Nx Atomizer

For more granular control over test distribution, Nx offers the Atomizer. This feature allows you to split tasks per file. This splitting further allows us to distribute long-running tasks across a larger number of agents, providing detailed insights into flaky tests and enabling automatic re-runs. If one of the flaky tests fails, we will still cache the results of all the other task slices and can even have a successful run if the flaky test re-run succeeded.

The `nx-e2e` task atomized to 13 e2e sub-tasks

With Atomizer, you can achieve a higher level of parallelism and ensure that only the necessary tests are executed, further optimizing your CI pipeline.

To enable the Atomizer, we need to use supported inferred plugins or create our own.

{
  // ...
  "plugins": [
    {
      "plugin": "@nx/cypress/plugin",
      "options": {
        "targetName": "e2e",
        "ciTargetName": "e2e-ci"
      }
    },
    {
      "plugin": "@nx/playwright/plugin",
      "options": {
        "targetName": "e2e",
        "ciTargetName": "e2e-ci"
      }
    },
    {
      "plugin": "@nx/jest/plugin",
      "options": {
        "targetName": "test",
        "ciTargetName": "test-ci"
      }
    },
    {
      "plugin": "@nx/gradle",
      "options": {
        "classesTargetName": "classes",
        "buildTargetName": "build",
        "testTargetName": "test",
        "ciTargetName": "test-ci"
      }
    }
  ]
}

The test-ci and e2e-ci targets will automatically be split into the following format:

  • e2e-ci--path/to/test/file
  • test-ci--path/to/test/file

Or more generically:

  • {ciTargetName}--{path/to/test/file}

You can find more information on how to configure the Atomizer on the respective Jest, Cypress, Playwright, Gradle or follow this recipe to create your own inferred plugin.

Manual E2E Project Splitting

In addition to automated splitting like sharding or atomization, manually splitting E2E projects into scopes can provide additional significant performance benefits.

Let's look at the simplified graph below:

Nx graph with single application, e2e project and several libraries

Our E2E project contains tests for each of the application features - products, orders and checkout. Any change made in the graph will cause all our E2E tests to be re-run. Even if we only modified products, we will still re-run the tests for orders and checkout. Although the Atomizer will help us split that work per file and distribute it, we will still end up running unnecessary work.

By defining scopes that implicitly depend on feature libraries rather than the entire application, you can ensure that only relevant tests are run when changes are made.

  • Scope Definition: Break down your E2E tests into smaller, focused scopes.
  • Dependency Management: Ensure that scopes depend on specific feature libraries, reducing unnecessary test execution.

Nx graph with several e2e applications depending on different scopes of the application

This approach offers both speed of distribution and caching efficiency. Every time the application is affected, we will only run the small subset of sanity smoke tests to ensure the application still runs, but specific features will only be tested if the relevant feature library has been modified or affected and skipped otherwise.

The tricky part comes from the fact that our split E2E applications still depend on the full application being served. But using the combination of implicitDependencies and dependsOn we can ensure that the application is running for our E2E tests without explicitly depending on it.

libs/checkout-e2e/project.json

{
  ...
  "implicitDependencies": ["checkout"],
  "targets": {
    "e2e": {
      "dependsOn": ["^build", { "target": "build", "projects": "app" }]
    }
  }
}

When we look at the graph, we will only see an edge from checkout-e2e to checkout, but having an explicit dependsOn app:build ensures that the build of the application was successful and the distributed agent running our E2E task has app's build cache replayed.

As of Nx version 20.8.0 you can now combine manual splitting with the Atomizer. In order to split atomized projects, we will have to override their dependsOn property to target also app:build:

libs/checkout-e2e/project.json

{
  ...
  "implicitDependencies": ["checkout"],
  "targets": {
    "e2e": {
      "dependsOn": ["^build", { "target": "build", "projects": "app" }]
    },
    "e2e-ci--**/**": {
      "dependsOn": ["^build", { "target": "build", "projects": "app" }]
    }
  }
}

This small improvement gives us the best of both worlds - using the Atomizer to automatically split long running tasks into smaller chunks and using manual splitting to skip entire work if dependencies haven't changed.

Conclusion

By implementing these techniques — the built-in test sharding, Nx Atomizer, and manual E2E project splitting — you can significantly cut down CI time. That means fewer bottlenecks, less time waiting on pipelines, and more time spent delivering features, fixing bugs, and improving the product. When CI runs faster, teams can iterate quickly, merge with confidence, and ship value to users without the drag of slow test cycles.

Faster CI is just the beginning. When combined with Nx Cloud's distributed task execution, these strategies not only bring stability and improved performance but also offer better developer ergonomics and a comprehensive overview of your testing processes. This powerful combination allows your team to ship with greater confidence.

Give these techniques a try and see the difference for yourself.