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=testAll lessons in this course
- Creating an Nx Monorepo with React Apps
- Shared Libraries & Internal Packages
- Nx Affected Commands & Caching
- Code Generators & Workspace Automation