testing-guidelines

작성자: sentry

테스트 작성 가이드. 새로운 기능 추가, 버그 수정, 또는 테스트가 필요할 때 사용합니다. 통합 테스트, 실제 환경 픽스처 등을 강조합니다.

npx skills add https://github.com/getsentry/warden --skill testing-guidelines

Testing Guidelines

Follow these principles when writing tests for this codebase.

Core Principles

1. Mock External Services, Use Real Fixtures

ALWAYS mock third-party network services. ALWAYS use fixtures based on real-world data.

  • Fixtures must be scrubbed of PII (use dummy data like foo@example.com, user-123)
  • Capture real API responses, then sanitize them
  • Never make actual network calls in tests

2. Prefer Integration Tests Over Unit Tests

Focus on end-to-end style tests that validate inputs and outputs, not implementation details.

  • Test the public interface, not internal methods
  • Unit tests are valuable for edge cases in pure functions, but integration tests are the priority
  • If refactoring breaks tests but behavior is unchanged, the tests were too coupled to implementation

3. Minimize Edge Case Testing

Don't test every variant of a problem.

  • Cover the common path thoroughly
  • Skip exhaustive input permutations
  • Skip unlikely edge cases that add maintenance burden without value
  • One representative test per category of input is usually sufficient

4. Always Add Regression Tests for Bugs

When a bug is identified, ALWAYS add a test that would have caught it.

  • The test should fail before the fix and pass after
  • Name it descriptively to document the bug
  • This prevents the same bug from recurring

Note: Regression tests are for unintentional broken behavior (bugs), not intentional changes. Intentional feature removals, deprecations, or breaking changes do NOT need regression tests—these are design decisions, not defects.

5. Cover Every User Entry Point

ALWAYS have at least one basic test for each customer/user entry point.

  • CLI commands, API endpoints, public/exported functions
  • Test the common/happy path first
  • This proves the entry point works at all

Note: "Entry point" means the public interface—exported functions, CLI commands, API routes. Internal/private functions are NOT entry points, even if they handle user-facing flags or options. Test entry points; internal functions get coverage through those tests.

6. Tests Validate Before Manual QA

Tests are how we validate ANY functionality works before manual testing.

  • Write tests first or alongside code, not as an afterthought
  • If you can't test it, reconsider the design
  • Passing tests should give confidence to ship

Technical Guidelines

File Organization

  • Test files use *.test.ts extension
  • Co-locate tests with source: foo.ts → foo.test.ts

Test Isolation

Every test must:

  • Run independently without affecting other tests
  • Use temporary directories for file operations
  • Clean up resources in afterEach hooks
import { describe, it, expect, beforeEach, afterEach } from 'vitest';
import { mkdirSync, rmSync, writeFileSync } from 'node:fs';
import { join } from 'node:path';
import { tmpdir } from 'node:os';

describe('my feature', () => {
  let tempDir: string;

  beforeEach(() => {
    tempDir = join(tmpdir(), `warden-test-${Date.now()}`);
    mkdirSync(tempDir, { recursive: true });
  });

  afterEach(() => {
    rmSync(tempDir, { recursive: true, force: true });
  });

  it('does something with files', () => {
    writeFileSync(join(tempDir, 'test.ts'), 'content');
    // ... test code
  });
});

Pure Function Tests

For pure functions without side effects, no special setup is needed:

import { describe, it, expect } from 'vitest';
import { matchGlob } from './matcher.js';

describe('matchGlob', () => {
  it('matches exact paths', () => {
    expect(matchGlob('src/index.ts', 'src/index.ts')).toBe(true);
  });
});

Running Tests

pnpm test              # Run all tests in watch mode
pnpm test:run          # Run all tests once

Checklist Before Submitting

  • New entry points have at least one happy-path test
  • Bug fixes (not intentional changes) include a regression test
  • External services are mocked with sanitized fixtures
  • Tests validate behavior, not implementation
  • No shared state between tests

sentry의 다른 스킬

add-ai-integration
sentry
Sentry JavaScript SDK에 새로운 AI 제공자 통합을 추가합니다. 새로운 AI 계측(OpenAI, Anthropic, Vercel AI, LangChain 등)을 기여할 때 사용하세요.
add-cdn-bundle
sentry
지정된 기능을 사용하여 브라우저 패키지용 새 CDN 번들을 생성합니다.
agent-prompt
sentry
효과적인 에이전트 프롬프트와 스킬 작성을 위한 참고 가이드입니다. 새로운 스킬을 만들거나 프롬프트 품질을 검토하거나 Warden의 프롬프트를 이해할 때 사용하세요.
agents-md
sentry
이 스킬은 사용자가 "AGENTS.md 생성", "AGENTS.md 업데이트", "에이전트 문서 유지", "CLAUDE.md 설정"을 요청하거나 에이전트를 유지해야 할 때 사용해야 합니다.
agents-md
sentry
60줄 미만의 최소화되고 핵심 정보를 담은 에이전트 문서를 생성 및 유지 관리합니다. 연구 기반의 에이전트 문서 모범 사례를 적용하며, 길이가 길어질수록 지침 품질이 저하됩니다. 패키지 관리자, 파일 범위 명령(파일별 테스트/린트/타입체크), 에이전트 ID를 포함한 커밋 속성의 세 가지 핵심 섹션이 필요합니다. 프로젝트 구조(잠금 파일, 린터 설정, CI 명령, 모노레포 표시)를 분석하여 파일에 포함할 내용을 결정합니다. 헤더와 불릿만 사용하며, 참조...
agents-md
sentry
이 스킬은 사용자가 "create AGENTS.md", "update AGENTS.md", "maintain agent docs", "set up CLAUDE.md"를 요청하거나 에이전트 문서를 유지해야 할 때 사용해야 합니다.
ai-sdk
sentry
ai-sdk — AI 에이전트용 설치 가능한 스킬, getsentry/webvitals.com에서 게시함.
analytics
sentry
Sentry의 프론트엔드 UI에서 analytics 이벤트를 계측하고 발견합니다. 버튼, 페이지, 모달 또는 사용자 정의 상호작용에 추적을 추가하거나 새로운 항목을 정의할 때 사용합니다.