home / skills / shaul1991 / shaul-agents-plugin / qa-tester

qa-tester skill

/skills/qa-tester

This skill assists in writing, executing, and validating unit, integration, and end-to-end tests using Jest and Supertest.

npx playbooks add skill shaul1991/shaul-agents-plugin --skill qa-tester

Review the files below or copy the command above to add this skill to your agents.

Files (1)
SKILL.md
3.0 KB
---
name: qa-tester
description: QA Tester Agent. 테스트 작성, 실행, 검증을 담당합니다. 테스트, 검증, 단위테스트, 통합테스트, E2E 관련 요청 시 사용됩니다.
allowed-tools: Bash(npm:*), Read, Write, Edit, Grep, Glob
---

# QA Tester Agent

## 역할
테스트 작성 및 실행을 담당합니다.

## 테스트 스택
- **Framework**: Jest
- **E2E**: Supertest
- **Mocking**: jest.mock, jest.spyOn

## 테스트 구조

```
test/
├── unit/                   # 단위 테스트
│   ├── services/
│   └── controllers/
├── integration/            # 통합 테스트
│   └── modules/
├── e2e/                    # E2E 테스트
│   ├── app.e2e-spec.ts
│   └── [feature].e2e-spec.ts
└── fixtures/               # 테스트 데이터
    └── [entity].fixture.ts
```

## 테스트 명령어

```bash
# 전체 테스트
npm run test

# 특정 파일 테스트
npm run test -- [file-pattern]

# 커버리지
npm run test:cov

# E2E 테스트
npm run test:e2e

# Watch 모드
npm run test:watch
```

## 테스트 패턴

### 단위 테스트
```typescript
describe('UserService', () => {
  let service: UserService;
  let repository: MockType<Repository<User>>;

  beforeEach(async () => {
    const module = await Test.createTestingModule({
      providers: [
        UserService,
        { provide: getRepositoryToken(User), useFactory: repositoryMockFactory },
      ],
    }).compile();

    service = module.get<UserService>(UserService);
    repository = module.get(getRepositoryToken(User));
  });

  describe('findById', () => {
    it('should return user when found', async () => {
      const user = { id: 1, name: 'Test' };
      repository.findOne.mockReturnValue(user);

      const result = await service.findById(1);

      expect(result).toEqual(user);
    });

    it('should throw when not found', async () => {
      repository.findOne.mockReturnValue(null);

      await expect(service.findById(1)).rejects.toThrow(NotFoundException);
    });
  });
});
```

### E2E 테스트
```typescript
describe('AppController (e2e)', () => {
  let app: INestApplication;

  beforeEach(async () => {
    const moduleFixture = await Test.createTestingModule({
      imports: [AppModule],
    }).compile();

    app = moduleFixture.createNestApplication();
    await app.init();
  });

  afterEach(async () => {
    await app.close();
  });

  it('/health/live (GET)', () => {
    return request(app.getHttpServer())
      .get('/health/live')
      .expect(200)
      .expect({ status: 'ok' });
  });
});
```

## 테스트 커버리지 목표

| 유형 | 목표 |
|------|------|
| 전체 | > 80% |
| 서비스 | > 90% |
| 컨트롤러 | > 70% |
| 유틸리티 | > 95% |

## 테스트 모범 사례

1. **AAA 패턴**: Arrange → Act → Assert
2. **단일 책임**: 하나의 테스트는 하나만 검증
3. **독립성**: 테스트 간 의존성 없음
4. **명확한 네이밍**: 무엇을 테스트하는지 명시

Overview

This skill is a QA Tester Agent for writing, running, and validating tests across unit, integration, and E2E layers. It uses Jest for unit and integration testing and Supertest for E2E requests, plus common mocking utilities. The agent enforces structure, coverage goals, and practical test patterns to keep test suites reliable and maintainable.

How this skill works

The agent generates and verifies tests following a clear folder layout for unit, integration, e2e, and fixtures. It produces Jest-compatible tests, uses jest.mock and jest.spyOn for isolating dependencies, and uses Supertest to exercise HTTP endpoints in E2E scenarios. It also runs tests with provided npm scripts and evaluates results against configured coverage targets.

When to use it

  • When you need unit tests for services, controllers, or utilities.
  • When validating full HTTP flows or API contracts via E2E tests.
  • When adding or updating features that require regression protection.
  • When you want automated coverage checks to meet quality gates.
  • When creating reproducible fixtures and mock-driven tests.

Best practices

  • Follow AAA (Arrange, Act, Assert) to make intent explicit.
  • Keep tests focused: one behavior per test for single responsibility.
  • Ensure test independence: avoid shared state between tests.
  • Name tests clearly to describe the scenario and expected outcome.
  • Mock external systems with jest.mock/jest.spyOn; use fixtures for data.

Example use cases

  • Write unit tests for a UserService with mocked repository methods.
  • Create E2E checks that hit /health/live and assert a 200 status and JSON response.
  • Add integration tests for module wiring and interaction of controllers and services.
  • Run coverage reports and enforce targets: overall >80%, services >90%, utilities >95%.
  • Execute watch mode during development to get rapid feedback on changes.

FAQ

What test commands are available?

Use npm run test for all tests, npm run test -- [file-pattern] for specific files, npm run test:cov for coverage, npm run test:e2e for E2E suites, and npm run test:watch for watch mode.

How is E2E testing performed?

E2E tests boot the application, use Supertest to make requests against the running server, and assert on HTTP responses and payloads.