소스 정보
- 저장소
- carrot-foundation/schemas
- 최근 소스 활동
- 2026년 3월 25일 20:55
- 감지된 SKILL.md 언어
- 영어
- 스타
- 1
- 포크
- 0
설치 방법
기본적으로 소스를 먼저 확인하는 Prompt가 선택됩니다. 직접 명령으로 전환하거나 로컬 사본을 다운로드할 수도 있습니다.
소스 파일 검토
설치 여부를 결정하기 전에 SKILL.md와 SkillsMP에 표시된 보조 파일을 읽어 보세요.
메뉴
기본적으로 소스를 먼저 확인하는 Prompt가 선택됩니다. 직접 명령으로 전환하거나 로컬 사본을 다운로드할 수도 있습니다.
설치 여부를 결정하기 전에 SKILL.md와 SkillsMP에 표시된 보조 파일을 읽어 보세요.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
직접 명령은 검토 Prompt를 거치지 않습니다. 실행하기 전에 소스를 확인하세요.
npx skills add https://github.com/carrot-foundation/schemas --skill rule-testing명령은 한 줄로 유지됩니다. 복사하기 전에 가로로 스크롤해 전체 내용을 확인하세요.
로컬 사본을 원하시나요? SkillsMP에서 현재 제공할 수 있는 파일을 다운로드하세요.
SOC 직업 분류 기준
SKILL.md 표시 중
| name | rule-testing |
| description | Vitest patterns, 100% coverage thresholds, and fixture-driven schema validation |
Apply this rule whenever work touches:
src/**/*.spec.tssrc/test-utils/**The schemas package enforces 100% test coverage. Every schema, utility, and export must be thoroughly tested because this is a published library — bugs propagate to every consumer.
Tests live in __tests__/ directories adjacent to the source code they test:
src/
mass-id/
__tests__/
mass-id.data.schema.spec.ts
mass-id.schema.spec.ts
mass-id.data.schema.ts
mass-id.schema.ts
shared/
schemas/
primitives/
__tests__/
ids.schema.spec.ts
ids.schema.ts
Always use the .spec.ts extension. Never use .test.ts — the project is configured for .spec.ts only.
Coverage thresholds are enforced at 100% for all metrics:
If coverage drops, add tests. Never reduce thresholds or delete tests to meet them.
Use centralized fixtures from src/test-utils/fixtures/ for valid data. Fixtures follow these conventions:
// src/test-utils/fixtures/mass-id-data.fixture.ts
export const MassIDDataFixture: MassIDData = {
type: 'Mass ID',
name: 'Test Mass ID',
weight_kg: 1500,
// ... all required fields with valid values
};
When tests need variations of valid data, use factory functions:
export function createMassIDDataFixture(
overrides?: Partial<MassIDData>,
): MassIDData {
return {
...MassIDDataFixture,
...overrides,
};
}
Before creating local test data, check src/test-utils/fixtures/ for existing fixtures. Import and override rather than duplicating.
.safeParse() for validation testsAlways use .safeParse() instead of .parse() in tests. This allows explicit assertions on both success and failure cases without try/catch.
// GOOD: safeParse for success
it('should accept valid mass-id data', () => {
const result = MassIDDataSchema.safeParse(MassIDDataFixture);
expect(result.success).toBe(true);
expect(result.data).toEqual(MassIDDataFixture);
});
// GOOD: safeParse for failure
it('should reject missing required field', () => {
const { name, ...withoutName } = MassIDDataFixture;
const result = MassIDDataSchema.safeParse(withoutName);
expect(result.success).toBe(false);
expect(result.error?.issues).toEqual(
expect.arrayContaining([expect.objectContaining({ path: ['name'] })]),
);
});
Every schema test suite must cover:
describe('LocationSchema', () => {
it('should accept valid complete location', () => { ... });
it('should accept location with only required fields', () => { ... });
it('should reject invalid latitude type', () => { ... });
it('should reject missing longitude', () => { ... });
it('should reject extra properties', () => { ... });
it('should reject latitude outside range [-90, 90]', () => { ... });
it('should accept optional description when present', () => { ... });
});
it.eachUse it.each for testing multiple inputs against the same assertion. This is especially useful for enum validations, boundary checks, and field type validations.
it.each([
['valid-uuid', true],
['not-a-uuid', false],
['', false],
['123e4567-e89b-12d3-a456-426614174000', true],
])('should validate UUID "%s" as %s', (input, expected) => {
const result = UuidSchema.safeParse(input);
expect(result.success).toBe(expected);
});
it.each([
['None', true],
['Low', true],
['Medium', true],
['High', true],
['none', false],
['NONE', false],
['Invalid', false],
])('should validate contamination level "%s" as %s', (input, expected) => {
const result = ContaminationLevelSchema.safeParse(input);
expect(result.success).toBe(expected);
});
Verify that Zod's inferred types match expected TypeScript types using expectTypeOf from Vitest:
import { expectTypeOf } from 'vitest';
it('should infer correct type from MassIDDataSchema', () => {
type Inferred = z.infer<typeof MassIDDataSchema>;
expectTypeOf<Inferred>().toMatchTypeOf<MassIDData>();
});
Follow the Arrange-Act-Assert pattern:
it('should reject weight below minimum', () => {
// Arrange
const input = createMassIDDataFixture({ weight_kg: -1 });
// Act
const result = MassIDDataSchema.safeParse(input);
// Assert
expect(result.success).toBe(false);
});
.only — committed tests must never use it.only or describe.onlyexpect(true).toBe(true) — always assert meaningful values