Angular Jest Unit Testing
Purpose
Use this skill to design or review Angular unit tests when the project uses Jest.
Jest should support clear, maintainable tests for components, services, pipes, and helpers. The focus is not on forcing a testing style, but on keeping tests readable, deterministic, and aligned with the application's architecture.
The core rule is simple:
Test behavior at the boundary you own.
When to Use
Use this skill when:
- the project already uses Jest
- unit tests need cleanup or structure
- TestBed usage needs guidance
- component or service mocking strategy is unclear
- test suites are becoming brittle or hard to read
Do
Use TestBed for Angular-aware component and service tests:
beforeEach(() => {
TestBed.configureTestingModule({
providers: [MyService],
});
});
Keep mocks narrow and intentional.
Assert behavior, not implementation details.
Prefer focused test names that describe user or service intent.
Do Not
Avoid rewriting the entire test stack during a local fix.
Avoid snapshot-only testing for dynamic Angular behavior.
Avoid overspecifying internal method calls when DOM or service behavior is the real contract.
Avoid mixing unrelated framework migrations into the testing work.
Review Checklist
- The project actually uses Jest.
- TestBed is used when Angular context is needed.
- Mocks are minimal and readable.
- Tests verify behavior, not private implementation details.
- The test suite remains maintainable.
Expected Output
When this skill is used, the agent should:
- Inspect the Jest-based test setup.
- Recommend a maintainable TestBed strategy.
- Define a minimal mocking approach.
- Flag brittle or overspecified tests.
- Produce focused test examples or refactors.
Source: janpereira-dev/ngAutoPilot — distributed by TomeVault.