con un clic
angular-testing
Generates Angular tests using Vitest and Testing Library
Instalar con Codex o Claude Copia este prompt, pégalo en Codex, Claude u otro asistente, y deja que revise la página de la skill y la instale por ti.
Menú
Generates Angular tests using Vitest and Testing Library
Instalar con Codex o Claude Copia este prompt, pégalo en Codex, Claude u otro asistente, y deja que revise la página de la skill y la instale por ti.
Basado en la clasificación ocupacional SOC
Generates Angular animations for smooth UI transitions and interactions
Generates Angular components with best practices and patterns
Generates an Angular dialog component extending BaseDialogComponent
Generates Angular directives for DOM manipulation and behavior enhancement
Generates Angular error boundary components for graceful error handling
Generates an Angular feature component (Standalone, OnPush)
| name | angular-testing |
| description | Generates Angular tests using Vitest and Testing Library |
This skill helps you create focused, effective tests for Angular components and services using Vitest.
import { TestBed } from '@angular/core/testing';
import { {{Name}}Service } from './{{name}}.service';
describe('{{Name}}Service', () => {
let service: {{Name}}Service;
beforeEach(() => {
TestBed.configureTestingModule({
providers: [{{Name}}Service]
});
service = TestBed.inject({{Name}}Service);
});
it('should be created', () => {
expect(service).toBeTruthy();
});
it('should handle state correctly', () => {
// Arrange
const testData = { /* test data */ };
// Act
service.updateState(testData);
// Assert
expect(service.state()).toEqual(testData);
});
});
import { TestBed } from '@angular/core/testing';
import { SettingsService } from './settings.service';
import { SettingsStorageUtil } from '../utils/storage.util';
// Mock the storage utility
jest.mock('../utils/storage.util');
describe('SettingsService', () => {
let service: SettingsService;
beforeEach(() => {
TestBed.configureTestingModule({
providers: [SettingsService]
});
service = TestBed.inject(SettingsService);
// Clear all mocks before each test
jest.clearAllMocks();
});
it('should be created', () => {
expect(service).toBeTruthy();
});
it('should get setting value', () => {
const mockSettings = { theme: 'dark' };
(SettingsStorageUtil.getAll as jest.Mock).mockReturnValue(mockSettings);
(SettingsStorageUtil.get as jest.Mock).mockReturnValue('dark');
const result = service.get('theme', 'light');
expect(result).toBe('dark');
expect(SettingsStorageUtil.get).toHaveBeenCalledWith('theme', 'light');
});
it('should set setting value', () => {
(SettingsStorageUtil.set as jest.Mock).mockReturnValue(true);
const result = service.set('theme', 'dark');
expect(result).toBe(true');
expect(SettingsStorageUtil.set).toHaveBeenCalledWith('theme', 'dark');
});
it('should handle signal updates', () => {
(SettingsStorageUtil.set as jest.Mock).mockReturnValue(true);
(SettingsStorageUtil.getAll as jest.Mock).mockReturnValue({ theme: 'dark' });
service.set('theme', 'dark');
// Test that signals are updated
expect(service.settings()).toEqual({ theme: 'dark' });
});
});
import { describe, it, expect, beforeEach } from 'vitest';
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { {{Name}}Component } from './{{name}}.component';
describe('{{Name}}Component', () => {
let component: {{Name}}Component;
let fixture: ComponentFixture<{{Name}}Component>;
beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [{{Name}}Component] // Standalone component
}).compileComponents();
fixture = TestBed.createComponent({{Name}}Component);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
it('should handle user interaction', () => {
// Test business logic, not DOM manipulation
component.onAction();
expect(component.state()).toBe(expectedState);
});
});