testing
npmLightweight testing utilities, headless browser mocks, and spy-backed providers for modern Angular.
pnpm add @angular-helpers/testingimport { render, provideMockService, setupHeadlessBrowserMocks } from '@angular-helpers/testing';
// Vitest / Jest setup
setupHeadlessBrowserMocks();
const { getByText } = await render(MyComponent, {
providers: [provideMockService(MyService)],
});🧪 Testing Primitives
render
Lightweight, intuitive component rendering utility for modern Angular unit tests. Supports signals, inputs, outputs, template projections, and custom providers without verbose TestBed boilerplate.
provideMockService
Creates auto-spied mocks for Angular services and providers. Replaces all methods with Vitest spies while preserving type signatures.
MockComponent
Creates lightweight stub components matching real component selectors and input/output contracts for shallow unit testing.
MockPipe
Creates a stub pipe that returns input value directly or custom transforms for test isolation.
provideMockRouter
Provides a mock Angular Router with spy-backed navigation methods (navigate, navigateByUrl) and observable URL events.
provideMockActivatedRoute
Provides a mock ActivatedRoute with configurable params, queryParams, and data streams/signals.
provideMockHttp
In-memory HTTP backend and MockHttpController for testing HttpClient requests with fluent expectations and responses.
flushEffects
Forces immediate synchronous evaluation of Angular effect() queues in test environments.
setupHeadlessBrowserMocks
Installs comprehensive, deterministic headless browser mocks (ResizeObserver, IntersectionObserver, BroadcastChannel, WebCrypto, Canvas2D) into globalThis.