소스 정보
- 저장소
- dev-hann/song
- 최근 소스 활동
- 2026년 2월 18일 13:08
- 감지된 SKILL.md 언어
- 영어
- 스타
- 0
- 포크
- 0
설치 방법
기본적으로 소스를 먼저 확인하는 Prompt가 선택됩니다. 직접 명령으로 전환하거나 로컬 사본을 다운로드할 수도 있습니다.
소스 파일 검토
설치 여부를 결정하기 전에 SKILL.md와 SkillsMP에 표시된 보조 파일을 읽어 보세요.
메뉴
기본적으로 소스를 먼저 확인하는 Prompt가 선택됩니다. 직접 명령으로 전환하거나 로컬 사본을 다운로드할 수도 있습니다.
설치 여부를 결정하기 전에 SKILL.md와 SkillsMP에 표시된 보조 파일을 읽어 보세요.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
직접 명령은 검토 Prompt를 거치지 않습니다. 실행하기 전에 소스를 확인하세요.
npx skills add https://github.com/dev-hann/song --skill api-testing명령은 한 줄로 유지됩니다. 복사하기 전에 가로로 스크롤해 전체 내용을 확인하세요.
로컬 사본을 원하시나요? SkillsMP에서 현재 제공할 수 있는 파일을 다운로드하세요.
Runs PM-Designer-Doc triple review protocol to reach consensus on feature specs before implementation. Includes domain documentation consistency check. Use before implementing any new screen, component, or significant feature.
Create Server and Client React components with proper props, state, and patterns
Enforce docs ↔ code consistency before and after implementation. Launches doc-reviewer agent to cross-check domain documentation against actual codebase, detects drift, and ensures documentation updates accompany code changes.
SOC 직업 분류 기준
SKILL.md 표시 중
| name | api-testing |
| description | Test API routes with proper validation, mocking, and error handling |
| license | MIT |
| compatibility | opencode |
| metadata | {"category":"testing","complexity":"intermediate"} |
Use this when you need to:
I'll ask clarifying questions if:
import { describe, it, expect, vi, beforeEach } from 'vitest';
import { GET } from '@/app/api/youtube/search/route';
describe('GET /api/youtube/search', () => {
let mockRequest: any;
beforeEach(() => {
vi.clearAllMocks();
mockRequest = {
url: new URL('http://localhost:3000/api/youtube/search'),
nextUrl: { searchParams: new URLSearchParams() }
};
});
it('should return 400 for missing query', async () => {
mockRequest.url.searchParams.get.mockReturnValueOnce(null);
const response = await GET(mockRequest);
expect(response.status).toBe(400);
expect(await response.json()).toEqual({
error: 'Query parameter "q" is required'
});
});
it('should return search results for valid query', async () => {
mockRequest....();
mockSearch = vi.().({
: [mockVideo],
:
});
vi.(, ({
: vi.().({ : mockSearch })
}));
response = (mockRequest);
data = response.();
(response.).();
(data.).();
});
});
import { vi, beforeEach } from 'vitest';
describe('API Route with External Dependencies', () => {
beforeEach(() => {
// Clear all mocks before each test
vi.clearAllMocks();
// Mock YouTube.js library
vi.mock('youtubei.js', () => ({
Innertube: {
create: vi.fn().mockResolvedValue({
search: vi.fn(),
getInfo: vi.fn()
})
}
}));
// Mock internal library
vi.mock('@/lib/youtube', () => ({
getInnertube: vi.fn(),
getYouTubeSession: vi.fn()
}));
});
it('should call getInnertube with correct config', async () => {
const mockRequest = createMockRequest({ q: 'test' });
await GET(mockRequest);
const { getInnertube } = await import('@/lib/youtube');
expect(getInnertube).toHaveBeenCalled();
});
});
describe('Error Handling', () => {
it('should return 500 on YouTube.js error', async () => {
vi.mock('@/lib/youtube', () => ({
getInnertube: vi.fn().mockRejectedValue(new Error('API Error'))
}));
const mockRequest = createMockRequest({ q: 'test' });
const response = await GET(mockRequest);
expect(response.status).toBe(500);
expect(await response.json()).toEqual({
error: 'Internal server error'
});
});
it('should return 404 for invalid video ID', async () => {
const mockGetInfo = vi.fn().mockResolvedValue(null);
vi.mock('@/lib/youtube', () => ({
getInnertube: vi.fn().mockResolvedValue({ getInfo: mockGetInfo })
}));
const mockRequest = createMockRequest({ : });
response = (mockRequest);
(response.).();
});
});
describe('Query Parameters', () => {
it('should parse query parameter', async () => {
const mockRequest = createMockRequest({ q: 'test' });
const response = await GET(mockRequest);
const data = await response.json();
expect(response.status).toBe(200);
});
it('should handle multiple parameters', async () => {
const mockRequest = createMockRequest({
q: 'test',
filter: 'video',
limit: '10'
});
const response = await GET(mockRequest);
const data = await response.json();
expect(response.status).toBe(200);
});
it('should validate parameter types', async () => {
const mockRequest = createMockRequest({ limit: 'invalid' });
const response = (mockRequest);
(response.).();
( response.()).({
:
});
});
});
describe('Response Format', () => {
it('should return JSON response', async () => {
const mockRequest = createMockRequest({ q: 'test' });
const response = await GET(mockRequest);
expect(response.headers.get('content-type')).toContain('application/json');
});
it('should include CORS headers', async () => {
const mockRequest = createMockRequest({ q: 'test' });
const response = await GET(mockRequest);
expect(response.headers.get('access-control-allow-origin')).toBe('*');
});
it('should have correct response structure', async () => {
const mockRequest = createMockRequest({ q: 'test' });
const response = await GET(mockRequest);
const data = await response.json();
(data).();
(.(data.)).();
});
});
// __tests__/utils/api-helpers.ts
export function createMockRequest(params: Record<string, string>): any {
const url = new URL(`http://localhost:3000/api/youtube/search`);
Object.entries(params).forEach(([key, value]) => {
url.searchParams.set(key, value);
});
return {
url,
nextUrl: { searchParams: url.searchParams }
};
}
export function createMockVideo(overrides = {}): Video {
return {
id: 'video123',
type: 'video',
title: 'Test Video',
description: 'Test Description',
duration: 120,
viewCount: 5000,
thumbnail: 'https://example.com/thumb.jpg',
channel: {
id: 'channel123',
name: 'Test Channel',
thumbnail: ''
},
...overrides
};
}
describe('GET /api/youtube/search', () => {
describe('Validation', () => {
it('should require query parameter');
it('should validate query type');
it('should validate optional parameters');
});
describe('Success Cases', () => {
it('should return search results');
it('should handle pagination');
it('should filter by type');
});
describe('Error Cases', () => {
it('should handle YouTube API errors');
it('should handle network errors');
it('should handle timeout errors');
});
describe('Response Format', () => {
it('should return JSON');
it('should include CORS headers');
it('should have correct structure');
});
});
describe('AAA Pattern Example', () => {
it('should return search results', async () => {
// Arrange
const mockRequest = createMockRequest({ q: 'test' });
const mockSearch = vi.fn().mockResolvedValue({
results: [createMockVideo()],
has_continuation: false
});
vi.mock('@/lib/youtube', () => ({
getInnertube: vi.fn().mockResolvedValue({ search: mockSearch })
}));
// Act
const response = await GET(mockRequest);
const data = await response.json();
// Assert
expect(response.status).toBe(200);
expect(data.results).toHaveLength(1);
expect(data.results[0].title).toBe('Test Video');
});
});