angular-testing

Test Angular services, queries, and components with Jest and TestBed.

10|7|Updated Jan 5, 2026
One-click install
npx skills add https://github.com/cuongtl1992/vibe-skills --skill angular-testing-cuongtl1992
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: angular-testing
Source: https://github.com/cuongtl1992/vibe-skills/tree/main/skills/frontend/angular-testing
Command: npx skills add https://github.com/cuongtl1992/vibe-skills --skill angular-testing-cuongtl1992

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Provides a standardized approach to Angular unit testing across services, queries, and components by enforcing the Arrange/Act/Assert pattern and offering guidance on mocking with InjectionToken to keep tests deterministic and maintainable.

Core Features & Use Cases

  • AAA testing pattern for organizing setup, execution, and validation in tests
  • Test file location convention: tests reside next to source files as .spec.ts
  • Core pattern: TestBed configuration with InjectionToken-based mocks
  • Signal-based component testing techniques to verify state and interactions
  • Guidance for testing use cases, queries, services, and components in real projects

Quick Start

Create a unit test file for a service using TestBed and Jest following the AAA pattern.

Frequently Asked Questions about angular-testing

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I mock services in Angular unit tests using InjectionToken?

Mock services in Angular unit tests by configuring TestBed with InjectionToken providers to supply deterministic test doubles. This approach keeps component testing maintainable by isolating dependencies without coupling tests to real repository implementations.

What is the best way to structure Angular Jest tests for maintainability?

The best way to structure Angular Jest tests is using the Arrange/Act/Assert (AAA) pattern to organize setup, execution, and validation. Co-locating test files as .spec.ts next to source files ensures structural consistency across services, queries, and components.

How do I test Angular signal-based components?

Test Angular signal-based components by configuring TestBed and verifying signal state changes and interactions directly. This technique validates component state updates and user interactions deterministically within the standard Jest testing environment.

Can I use Jest with TestBed for Angular component testing without real dependencies?

Yes, you can use Jest with TestBed for Angular component testing by overriding real dependencies with InjectionToken-based mocks. This configuration isolates component behavior, ensuring tests remain deterministic and focused on component logic rather than service implementation details.

Why does my Angular unit test fail when injecting a repository?

Angular unit tests fail when injecting a repository if TestBed is not configured with the correct InjectionToken mock provider. Registering mock implementations via InjectionToken ensures the dependency injection container resolves test doubles instead of real services during execution.

What file naming convention should I use for Angular unit testing?

Use the .spec.ts suffix for Angular unit testing file naming conventions. Co-locating these .spec.ts files directly next to their corresponding source files ensures easy discovery and maintains structural consistency across the frontend project.