Camila E. Blanc Fick

Nx Angular App test

It took me hours to reach my initial goal, create an app that has routing, unit test with karma and e2e tests with cypress.

Workspace setup

  • First step is to create an empty workspace.
npx create-nx-workspace@latest
Workspace name (e.g., org name)     camixdev
What to create in the new workspace empty
CLI to power the Nx workspace Nx
Use Nx Cloud? No
  • Second step: inside camixdev run:
npm add -D @nrwl/angular
  • Third step: same pwd, run:
nx generate @nrwl/angular:application --name=pokemon 
--unitTestRunner=karma --e2eTestRunner=cypress --routing=true --style=scss

Now hands on!

Useful things:

# Generate UI lib
ng g @nrwl/angular:lib ui

# Add a component
ng g @nrwl/angular:component xyz --project ui

# View dependency graph
nx dep-graph

# see what's been affected by changes
ng affected:dep-graph

# run tests for current changes
ng affected:test

# run e2e tests for current changes
ng affected:e2e

over 3 years ago

Camila Blanc