A powerful Angular testing library that simplifies unit tests by removing boilerplate and providing a clean API.
Spectator is a testing library for Angular applications designed to eliminate repetitive boilerplate code, making unit tests more readable and maintainable. It provides a streamlined API for testing components, directives, services, pipes, HTTP calls, and routing, while supporting Jasmine, Jest, and Vitest test runners.
Angular developers writing unit tests for components, directives, services, pipes, HTTP services, and routing, especially those seeking to reduce boilerplate and improve test clarity. It is suitable for teams using Jasmine, Jest, or Vitest as their test framework.
Developers choose Spectator over plain Angular TestBed or other utilities because it drastically reduces test setup boilerplate with a clean, declarative API and built-in helpers for DOM querying, event simulation, and custom matchers. Its unique selling point is comprehensive support for the entire Angular testing surface (including deferrable views and standalone components) with strong typing and flexibility across multiple test runners.
🦊 🚀 A Powerful Tool to Simplify Your Angular Tests
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Supports testing of components, directives, services, pipes, HTTP, routing, and even niche features like deferrable views and standalone components, as detailed in the README's extensive API sections.
Offers clean querying with helpers like byText and byRole, plus event simulation for keyboard, mouse, and touch, drastically reducing boilerplate compared to vanilla Angular tests.
Compatible with Jasmine, Jest, and Vitest, allowing seamless integration with various project setups, as shown in the dedicated support sections.
Includes matchers like toHaveClass and toBeDisabled for readable assertions, enhancing test clarity without external libraries.
Adds a layer over Angular TestBed that can obscure native testing mechanics, making debugging harder when tests fail due to hidden configurations.
The many options in factory functions (e.g., createComponentFactory with over 15 parameters) can overwhelm developers and lead to verbose, error-prone setups.
For advanced mocking, the README recommends integrating with ng-mocks, adding another library dependency and potential compatibility issues.