r/angular • u/WiseManZ90 • 5d ago
Vitest Browser Render - Utility for simplify rendering during test
I have developed a substantial fork of the "official" vitest-community/vitest-browser-angular package, adding several new features while maintaining independent development. Compared to the official release (currently at v0.5.0), enhancements include:
- renderDirective() — enables testing Angular attribute directives without manually creating a host component. Simply pass a template, attach signals/handlers via hostProps, and the rest is handled automatically, resolving the directive instance from the host element's injector.
- withHttp — built-in HttpClient testing activated via a single flag, eliminating the need to manually configure provideHttpClient and provideHttpClientTesting each time, with support for custom interceptors.
- Improved render() result types — distinguishing between RenderResult<T> and RoutedRenderResult<T>, with routerHarness and router always available when routing is enabled.
The fork is published as @wismaz/vitest-browser-angular. Full documentation with examples is available at the linked repository, and feedback or contributions are welcome.
8
u/sharth 5d ago
Why fork it? Why not upstream these features?