# Angular Testing and Architecture Apply these rules when writing Angular tests, organizing features, or changing Angular package versions. The TypeScript testing, coding-style, and dependency rules and the shared refactoring rule cover general test design, structure, and dependency review; this file adds Angular specifics. ## Testing * Use the project's test runner. New CLI projects use Vitest since Angular 21; Karma remains supported, so do not migrate runners as part of another task. * In zoneless tests, configure `TestBed` with `provideZonelessChangeDetection()` and use `await fixture.whenStable()` instead of `fakeAsync` and `tick`, which require zone.js. * Set signal inputs with `fixture.componentRef.setInput()`. Test HTTP with `provideHttpClient()` plus `provideHttpClientTesting()` and `HttpTestingController`. Prefer Angular CDK component harnesses for Material and CDK components. * Test critical user interactions through the rendered component rather than its internals. ## Architecture * Organize code by feature, and keep UI, application, domain, and data-access concerns separate where practical. * Keep feature public APIs small; avoid cross-feature imports without a clear contract, and keep shared code genuinely shared. * Prefer local ownership of state and logic. ## Versions and dependencies * Check the Angular version in `package.json` before using version-specific APIs. * Keep all `@angular/*` packages on the same major and minor version, and upgrade them with `ng update` so migrations run. * Keep TypeScript inside the range the Angular version supports (angular.dev/reference/versions); Angular 22 requires TypeScript `>=6.0.0 <6.1.0`, so do not move an Angular project to TypeScript 7 before Angular supports it. * Treat Angular compiler, template type-checking, and lint warnings seriously; do not suppress them without a concrete reason. * Prefer Angular and browser platform capabilities before adding third-party libraries.