TE

test-automation

Automate the creation of Vitest unit tests for Angular components, services, and Firebase integration.

Install

mkdir -p .claude/skills/test-automation && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/9272" && unzip -o skill.zip -d .claude/skills/test-automation && rm skill.zip

Installs to .claude/skills/test-automation

Activation

This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.

Generate and manage Vitest tests for Angular components, services, and Firebase integrations
92 charsno explicit “when” trigger
Beginner

Key capabilities

  • Scaffold Vitest test files for Angular components
  • Generate boilerplate for services and providers
  • Create templates for Firestore rules testing
  • Configure test coverage reporting
  • Mock external dependencies for unit tests

How it works

Uses predefined templates and common testing patterns to generate structural test skeletons with necessary mocks.

Inputs & outputs

You give it
Angular component or service source file
You get back
Spec file with standard test scaffolding

When to use test-automation

  • Creating unit tests for angular services
  • Scaffolding component tests with vitest
  • Testing firestore rules with emulators
  • Running code coverage reports

About this skill

Test Automation Skill

Generate comprehensive Vitest tests for the quantified-self Angular application.

Testing Framework

AspectConfiguration
FrameworkVitest v3.x
Angular Plugin@analogjs/vite-plugin-angular
Environmentjsdom
Coverage@vitest/coverage-v8

Commands

# Run all tests
npm test

# Run with coverage
npm run test-coverage

# Run Firestore rules tests (requires emulator)
npm run test:rules

Test File Patterns

1. Service Test Template

import { TestBed } from '@angular/core/testing';
import { vi, describe, it, expect, beforeEach, afterEach, Mock } from 'vitest';
import { MyService } from './my.service';

// Hoist mocks BEFORE vi.mock() calls
const mocks = vi.hoisted(() => ({
  myMockedFn: vi.fn(),
}));

// Mock external modules
vi.mock('@angular/fire/firestore', async (importOriginal) => {
  const actual = await importOriginal<typeof import('@angular/fire/firestore')>();
  return { ...actual, doc: vi.fn(), docData: vi.fn() };
});

describe('MyService', () => {
  let service: MyService;

  beforeEach(() => {
    TestBed.configureTestingModule({
      providers: [
        MyService,
        { provide: SomeDep, useValue: mockDep },
      ]
    });
    service = TestBed.inject(MyService);
    vi.clearAllMocks();
  });

  afterEach(() => {
    vi.restoreAllMocks();
  });

  it('should be created', () => {
    expect(service).toBeTruthy();
  });
});

2. Component Test Template

import { ComponentFixture, TestBed } from '@angular/core/testing';
import { vi, describe, it, expect, beforeEach } from 'vitest';
import { MyComponent } from './my.component';

describe('MyComponent', () => {
  let component: MyComponent;
  let fixture: ComponentFixture<MyComponent>;

  beforeEach(async () => {
    await TestBed.configureTestingModule({
      imports: [/* required modules */],
      declarations: [MyComponent],
      providers: [/* mocked services */]
    }).compileComponents();

    fixture = TestBed.createComponent(MyComponent);
    component = fixture.componentInstance;
    fixture.detectChanges();
  });

  it('should create', () => {
    expect(component).toBeTruthy();
  });
});

Mocking Patterns

Firebase/Firestore Mocking

vi.mock('@angular/fire/firestore', async (importOriginal) => {
  const actual = await importOriginal<typeof import('@angular/fire/firestore')>();
  return {
    ...actual,
    doc: vi.fn(),
    docData: vi.fn(() => of(mockData)),
    collection: vi.fn(),
    collectionData: vi.fn(() => of([mockItem])),
    deleteDoc: vi.fn().mockResolvedValue(undefined),
    setDoc: vi.fn().mockResolvedValue(undefined),
  };
});

RxJS Observables

import { of, throwError } from 'rxjs';

// Success
(someMethod as Mock).mockReturnValue(of(mockData));

// Error
(someMethod as Mock).mockReturnValue(throwError(() => new Error('Test error')));

Browser APIs

// Store original before modifying
const originalAPI = globalThis.SomeAPI;

beforeEach(() => {
  globalThis.SomeAPI = vi.fn().mockImplementation(() => ({ /* mock */ }));
});

afterEach(() => {
  globalThis.SomeAPI = originalAPI;
});

Key Differences from Jasmine/Karma

Jasmine/KarmaVitest
jasmine.createSpy()vi.fn()
spyOn(obj, 'method')vi.spyOn(obj, 'method')
and.returnValue().mockReturnValue()
and.callFake().mockImplementation()
toHaveBeenCalledWith()toHaveBeenCalledWith()
jasmine.any(Type)expect.any(Type)

Coverage Analysis

# Generate coverage report
npm run test-coverage

# Output: coverage/index.html

Checklist for New Tests

  • Import from vitest: vi, describe, it, expect, beforeEach, afterEach
  • Use vi.hoisted() for mock values needed in vi.mock()
  • Mock Firebase modules with async (importOriginal) pattern
  • Use vi.clearAllMocks() in beforeEach
  • Use vi.restoreAllMocks() in afterEach
  • Cast mocks with as Mock for .mockReturnValue() calls

When not to use it

  • Backend testing outside of the Firebase scope
  • When a test engineering sub-agent is required for complex logic

Prerequisites

Vitest v3.x, @analogjs/vite-plugin-angular

Limitations

  • Requires manual implementation of complex logic inside test blocks
  • Cannot verify integration against live Firebase environments

How it compares

It specifically targets Angular-to-Firebase patterns rather than generating generic JavaScript tests.

Compared to similar skills

test-automation side by side with the closest alternatives in the catalog.

SkillInstallsUpdatedSafetyDifficulty
test-automation (this skill)06moReviewBeginner
angular1004moReviewAdvanced
angular-best-practices213moNo flagsAdvanced
angular-state-management84moNo flagsIntermediate

Try saying

Example prompts that trigger this skill in your AI assistant.

You might also like

angular

sickn33

Modern Angular (v20+) expert with deep knowledge of Signals, Standalone Components, Zoneless applications, SSR/Hydration, and reactive patterns. Use PROACTIVELY for Angular development, component architecture, state management, performance optimization, and migration to modern patterns.

100129

angular-best-practices

sickn33

Angular performance optimization and best practices guide. Use when writing, reviewing, or refactoring Angular code for optimal performance, bundle size, and rendering efficiency.

2192

angular-state-management

sickn33

Master modern Angular state management with Signals, NgRx, and RxJS. Use when setting up global state, managing component stores, choosing between state solutions, or migrating from legacy patterns.

823

angular-modernization

bitwarden

Modernizes Angular code such as components and directives to follow best practices using both automatic CLI migrations and Bitwarden-specific patterns. YOU must use this skill when someone requests modernizing Angular code. DO NOT invoke for general Angular discussions unrelated to modernization.

422

angular-routing

analogjs

Implement routing in Angular v20+ applications with lazy loading, functional guards, resolvers, and route parameters. Use for navigation setup, protected routes, route-based data loading, and nested routing. Triggers on route configuration, adding authentication guards, implementing lazy loading, or reading route parameters with signals.

14

igniteui-angular-grids

igniteui

Provides guidance on all Ignite UI for Angular data grid types (Flat Grid, Tree Grid, Hierarchical Grid, Grid Lite, Pivot Grid) including setup, column configuration, sorting, filtering, selection, editing, grouping, summaries, toolbar, export, paging, remote data, and state persistence. Use when users ask about grids, tables, data grids, tabular data display, cell editing, batch editing, row selection, column pinning, column hiding, grouping rows, pivot tables, tree-structured data, hierarchical data, master-detail views, or exporting grid data.

14

Search skills

Search the agent skills registry