0PricingLogin
React Academy · Lesson

Nx Affected Commands & Caching

Run only tests and builds affected by a change, and speed up CI with Nx Cloud distributed caching.

The Affected Concept

Nx tracks the dependency graph of your monorepo. When you change a file, Nx computes which projects are affected (directly modified or depend on modified projects) and runs tasks only for those.

Running Affected Tests

Run tests only for projects affected by changes since the main branch.

# Compare to main branch:
npx nx affected --target=test --base=origin/main --head=HEAD

# Shorthand (uses nx.json defaultBase):
npx nx affected --target=test

All lessons in this course

  1. Creating an Nx Monorepo with React Apps
  2. Shared Libraries & Internal Packages
  3. Nx Affected Commands & Caching
  4. Code Generators & Workspace Automation
← Back to React Academy