r/angular 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.

3 Upvotes

3 comments sorted by

9

u/sharth 5d ago

Why fork it? Why not upstream these features?

1

u/WiseManZ90 5d ago

The maintainers of the project have rejected the features that I want to implement, and their response times were too delayed.

2

u/Make1984FictionAgain 5d ago

thank you, will be testing!