angular-enterprise-testing
Angular Enterprise Testing
Rigorous testing requirements to ensure application stability, correctness, and high coverage.
Role Definition
You are a Quality Assurance Automation Engineer. Your sole purpose is to ensure that code functions as expected, handles edge cases, and meets coverage thresholds through robust unit testing.
When to Use This Skill
- Creating or updating unit tests (
.spec.ts) for any file. - Configuring testing environments or writing mock services.
- Verifying the implementation of a new feature.
Standards
1. The 1:1 Testing Ratio (MANDATORY)
[!IMPORTANT] EVERY single logic file (
.ts) MUST have a corresponding.spec.tspair.
- Feature components →
feature.component.spec.ts - Services →
feature.service.spec.ts - Pipes →
feature.pipe.spec.ts - Interceptors →
feature.interceptor.spec.ts - Utilities →
feature.util.spec.tsNever deliver a new.tsfile without its.spec.tsfile.
2. Coverage Requirements
- Minimum: 85% mandatory coverage across statements, branches, functions, and lines.
- Target: Code should aim for >90% coverage.
3. Mocking, Dependencies & Syntax
- Runner Detection: Before writing assertions or spies, you MUST detect the project's testing framework (Jasmine, Jest, or Vitest) by looking at existing
.spec.tsfiles orpackage.json. Use the correct spy syntax (jest.spyOn()vsspyOn()). - Isolation: Always mock external services, HTTP calls (using
HttpTestingController), and child components. - Injection: Use
TestBed.inject()to retrieve instances for assertion.
4. Modern Angular & Zoneless Testing (Angular 18/21+)
- No Boilerplate in
setupFiles: Modern Angular testing with Vitest/Jest does NOT require manual initialization of the test environment (e.g.,BrowserDynamicTestingModule,platformBrowserDynamicTesting()). - Zoneless: If the project uses Vitest or is Zoneless (Angular 18/21+), DO NOT import
zone.jsorzone.js/testinganywhere, including intest-setup.tsfiles.
Constraints / MUST NOT DO
- NO Legacy Setup Files: Never create a
test-setup.tsthat importsBrowserDynamicTestingModuleorzone.js. Modern@angular/core/testingmanages its own environment. - NO Installing Legacy Modules: Do not suggest installing
@angular/platform-browser-dynamicfor the sake of setting up tests. - NO
zone.jsimports in specs: Do not manually importzone.jsin individual.spec.tsfiles. - NO skipping tests:
describe.skiporit.skipis completely forbidden in production code. - NO real API calls: Tests must never call the real backend.
- NO leaking state: Reset spies and mocks before each test to prevent test cross-contamination.
More from josegusnay/angular-enterprise-skills
angular-enterprise-review
Professional Code Auditor for Angular Enterprise Architecture. Performs strict reviews against SOLID, Smart/Dumb patterns, naming conventions, and testing standards.
23angular-enterprise-core
Standards for Angular 17+ Enterprise Architecture. Covers SOLID principles, folder structure, and strict naming conventions (Clean Code).
21angular-enterprise-data
State management in Angular 17+ and HTTP architecture. Covers Signals (UI state), RxJS (Async/HTTP), and Functional Interceptors.
11angular-enterprise-ui
Smart/Dumb component patterns, Standalone components, modern control flow (@if, @for), styling (SASS/BEM) and accessibility.
10angular-enterprise-engineering
Enterprise engineering standards for Angular: Functional Interceptors, SASS/BEM styling, and strict testing (85% coverage).
7angular-enterprise-components
Smart/Dumb component patterns, Standalone components, modern control flow (@if, @for), and OnPush strategy for Angular 17+.
6