[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6DW2YS1MGF65JNS1QQ15QHS":3,"skill-same:01M6DW2YS1MGF65JNS1QQ15QHS":72},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":39,"linkOnly":40,"markdownContent":41,"markdownBody":42,"frontMatter":43,"refName":44,"commitSha":45,"skillDirectory":46,"forksCount":47,"repositoryHtmlUrl":48,"repositoryHomepageUrl":6,"ownerHtmlUrl":49,"ownerBlogUrl":50,"ownerDescription":6,"updatedAt":51,"install":52,"resources":65},"01M6DW2YS1MGF65JNS1QQ15QHS","vitest-test-conventions",null,"ACTIVATE when writing Vitest tests, creating test files, using vi.fn()\u002Fvi.mock()\u002Fvi.spyOn(), or test factories. ACTIVATE for 'Vitest', 'it.each', 'NestJS testing module', 'supertest', 'vi.fn', 'vi.mock', 'spyOn'. Provides Vitest\u002FNestJS-specific testing patterns; cross-language testing principles (DAMP, AAA, spy over mock, what NOT to test) live in craft:testing-principles. DO NOT use for: node:test files (a file importing node:test) or a project whose tests run under node --test (see node-test:node-test-conventions), TDD workflow\u002Fiterations (see vitest:vitest-tdd-workflow), PHP\u002FPHPUnit tests (see phpunit:php-test-conventions).","FabienSalles\u002Fclaude-marketplace","FabienSalles","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F937901?v=4","01M6DVJBD31CJKRB382FQFZ5FH","Fabien Salles","01M6DVJBQNY8Q18KJD1ESAD6TX",9,"MIT","https:\u002F\u002Fgithub.com\u002FFabienSalles\u002Fclaude-marketplace\u002Fblob\u002Fmain\u002Fplugins\u002Fvitest\u002Fskills\u002Fvitest-test-conventions\u002FSKILL.md",[],[19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38],"vitest test conventions","test","vitest","conventions","nestjs","testing principles","fn","module","tests","project","do","activate","testing","files","use","testing patterns","file","workflow","tdd","writing","2026-11-10 10:12:30",false,"---\nname: vitest-test-conventions\ndescription: \"ACTIVATE when writing Vitest tests, creating test files, using vi.fn()\u002Fvi.mock()\u002Fvi.spyOn(), or test factories. ACTIVATE for 'Vitest', 'it.each', 'NestJS testing module', 'supertest', 'vi.fn', 'vi.mock', 'spyOn'. Provides Vitest\u002FNestJS-specific testing patterns; cross-language testing principles (DAMP, AAA, spy over mock, what NOT to test) live in craft:testing-principles. DO NOT use for: node:test files (a file importing node:test) or a project whose tests run under node --test (see node-test:node-test-conventions), TDD workflow\u002Fiterations (see vitest:vitest-tdd-workflow), PHP\u002FPHPUnit tests (see phpunit:php-test-conventions).\"\n---\n\n# Test Conventions — Vitest\n\n> The **cross-language testing principles** (DAMP, AAA, spy over mock, what NOT to test, factories, structured assertions) are defined in `craft:testing-principles`. This skill keeps Vitest \u002F NestJS-specific patterns.\n\n> See also: `vitest-tdd-workflow` for TDD workflow and iteration patterns.\n\n## Test Types (Vitest + NestJS)\n\n| Test Type | Setup | File pattern |\n|-----------|-------|--------------|\n| Unit | No DI container, pure logic | `*.spec.ts` |\n| Integration | NestJS `Test.createTestingModule()` | `*.integration-spec.ts` |\n| E2E | `supertest` + full app | `*.e2e-spec.ts` |\n\n## Vitest-specific: Test Doubles\n\n```typescript\nvi.fn()    \u002F\u002F Standalone callback or function double; a port gets an in-memory stub instead\nvi.spyOn() \u002F\u002F Wraps one method of a real object, leaving the rest real\nvi.mock()  \u002F\u002F Module-level replacement, for what cannot be injected\n```\n\n> When writing test doubles, parameterized tests, or factory functions, read `references\u002Ftest-examples.md` for complete `vi.fn`\u002F`spyOn`\u002F`mock` patterns, `it.each` examples, and factory patterns.\n\n## Vitest-specific: `it.each()` Format Selection\n\n- **Majority of strings** → template literal syntax (tabular reading).\n- **Mix of types or majority non-string** → object syntax (avoids verbose `${}`).\n\n> When writing exception tests or NestJS integration tests, read `references\u002Ftest-examples.md` for `toThrow` patterns and `Test.createTestingModule` setup.\n\n## Vitest-specific: Structured Assertions\n\n```typescript\n\u002F\u002F Compare full object\nexpect(result).toEqual({ id: 1, name: 'Alice' });\n\n\u002F\u002F Partial match\nexpect(result).toEqual(expect.objectContaining({ id: 1 }));\n```\n\n## NestJS-specific: Integration Test Setup\n\n```typescript\n\u002F\u002F references\u002Ftest-examples.md has the complete pattern\nconst module = await Test.createTestingModule({\n  providers: [ReceiptService, { provide: RepositoryToken, useClass: InMemoryRepo }],\n}).compile();\n\nconst service = module.get(ReceiptService);\n```\n\n## Vitest-specific: Characterization Pin\n\nBefore changing behaviour no test pins, freeze the inputs and compare today's output, quirks included, to a committed golden file. The order, the gates and the retirement rules live in `craft:testing-principles` §16.\n\n```typescript\nit('keeps today\\'s summaries, quirk included', () => {\n  const frozen = [summarize('R-1', [10, 2.5, 0]), summarize('R-0', [])];\n  const golden = readFileSync(new URL('.\u002Freceipt-summary.golden.txt', import.meta.url), 'utf8');\n\n  expect(`${frozen.join('\\n')}\\n`).toBe(golden);\n});\n```\n\nThe golden file is plain text read with `node:fs`: no snapshot API.\n\n## Quick Reference (Vitest-specific)\n\n| Situation | Approach |\n|-----------|----------|\n| Simple value objects | Direct instantiation |\n| Port dependency | In-memory stub that is its own spy |\n| Spy on real method | `vi.spyOn()` |\n| Module replacement | `vi.mock()` |\n| Same logic, different data | `it.each()` (object or template literal) |\n| Verify method called | `expect(spy).toHaveBeenCalledWith(...)` after act |\n| Compare objects | `toEqual` + `expect.objectContaining` |\n","# Test Conventions — Vitest\n\n> The **cross-language testing principles** (DAMP, AAA, spy over mock, what NOT to test, factories, structured assertions) are defined in `craft:testing-principles`. This skill keeps Vitest \u002F NestJS-specific patterns.\n\n> See also: `vitest-tdd-workflow` for TDD workflow and iteration patterns.\n\n## Test Types (Vitest + NestJS)\n\n| Test Type | Setup | File pattern |\n|-----------|-------|--------------|\n| Unit | No DI container, pure logic | `*.spec.ts` |\n| Integration | NestJS `Test.createTestingModule()` | `*.integration-spec.ts` |\n| E2E | `supertest` + full app | `*.e2e-spec.ts` |\n\n## Vitest-specific: Test Doubles\n\n```typescript\nvi.fn()    \u002F\u002F Standalone callback or function double; a port gets an in-memory stub instead\nvi.spyOn() \u002F\u002F Wraps one method of a real object, leaving the rest real\nvi.mock()  \u002F\u002F Module-level replacement, for what cannot be injected\n```\n\n> When writing test doubles, parameterized tests, or factory functions, read `references\u002Ftest-examples.md` for complete `vi.fn`\u002F`spyOn`\u002F`mock` patterns, `it.each` examples, and factory patterns.\n\n## Vitest-specific: `it.each()` Format Selection\n\n- **Majority of strings** → template literal syntax (tabular reading).\n- **Mix of types or majority non-string** → object syntax (avoids verbose `${}`).\n\n> When writing exception tests or NestJS integration tests, read `references\u002Ftest-examples.md` for `toThrow` patterns and `Test.createTestingModule` setup.\n\n## Vitest-specific: Structured Assertions\n\n```typescript\n\u002F\u002F Compare full object\nexpect(result).toEqual({ id: 1, name: 'Alice' });\n\n\u002F\u002F Partial match\nexpect(result).toEqual(expect.objectContaining({ id: 1 }));\n```\n\n## NestJS-specific: Integration Test Setup\n\n```typescript\n\u002F\u002F references\u002Ftest-examples.md has the complete pattern\nconst module = await Test.createTestingModule({\n  providers: [ReceiptService, { provide: RepositoryToken, useClass: InMemoryRepo }],\n}).compile();\n\nconst service = module.get(ReceiptService);\n```\n\n## Vitest-specific: Characterization Pin\n\nBefore changing behaviour no test pins, freeze the inputs and compare today's output, quirks included, to a committed golden file. The order, the gates and the retirement rules live in `craft:testing-principles` §16.\n\n```typescript\nit('keeps today\\'s summaries, quirk included', () => {\n  const frozen = [summarize('R-1', [10, 2.5, 0]), summarize('R-0', [])];\n  const golden = readFileSync(new URL('.\u002Freceipt-summary.golden.txt', import.meta.url), 'utf8');\n\n  expect(`${frozen.join('\\n')}\\n`).toBe(golden);\n});\n```\n\nThe golden file is plain text read with `node:fs`: no snapshot API.\n\n## Quick Reference (Vitest-specific)\n\n| Situation | Approach |\n|-----------|----------|\n| Simple value objects | Direct instantiation |\n| Port dependency | In-memory stub that is its own spy |\n| Spy on real method | `vi.spyOn()` |\n| Module replacement | `vi.mock()` |\n| Same logic, different data | `it.each()` (object or template literal) |\n| Verify method called | `expect(spy).toHaveBeenCalledWith(...)` after act |\n| Compare objects | `toEqual` + `expect.objectContaining` |\n",{"name":5,"description":7},"main","479b264ec17cc5fafbf36287a1087472d3a386d3","plugins\u002Fvitest\u002Fskills\u002Fvitest-test-conventions",2,"https:\u002F\u002Fgithub.com\u002FFabienSalles\u002Fclaude-marketplace","https:\u002F\u002Fgithub.com\u002FFabienSalles","https:\u002F\u002Ffabiensalles.com","2026-10-13 04:33:22",{"source":8,"skillName":5,"commands":53,"prompt":63,"zipAvailable":64},[54,57,60],{"tool":55,"command":56},"npx","npx skills add FabienSalles\u002Fclaude-marketplace --skill vitest-test-conventions",{"tool":58,"command":59},"bunx","bunx skills add FabienSalles\u002Fclaude-marketplace --skill vitest-test-conventions",{"tool":61,"command":62},"pnpm","pnpm dlx skills add FabienSalles\u002Fclaude-marketplace --skill vitest-test-conventions","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FFabienSalles\u002Fclaude-marketplace\u002Fblob\u002Fmain\u002Fplugins\u002Fvitest\u002Fskills\u002Fvitest-test-conventions\u002FSKILL.md",true,[66],{"path":67,"resourceType":68,"resourceTypeDesc":69,"sizeBytes":70,"sourceHtmlUrl":71},"references\u002Ftest-examples.md","REFERENCE","参考文档",4405,"https:\u002F\u002Fgithub.com\u002FFabienSalles\u002Fclaude-marketplace\u002Fblob\u002Fmain\u002Fplugins\u002Fvitest\u002Fskills\u002Fvitest-test-conventions\u002Freferences\u002Ftest-examples.md",[73,89,110,132,149,166],{"skillNo":74,"name":75,"nameZh":6,"description":76,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":77,"categories":78,"keywords":79,"publishedAt":39},"01M6DW2VFE6NPFCGQKQ68P1MVZ","vitest-tdd-workflow","ACTIVATE when building new features, endpoints, or user stories using TDD with Vitest in a TypeScript\u002FNestJS context. ACTIVATE for '\u002Ffeature-tdd-dev', 'TDD', 'red-green-refactor' in TS context. Provides Vitest\u002FNestJS-specific TDD examples and commands; cross-language TDD workflow (cross-layer iterations, RED-GREEN-REFACTOR, working app, bug-fix-first-test, mocks-hiding-bugs) lives in craft:tdd-workflow-principles. DO NOT use for: node:test files (a file importing node:test) or a project whose tests run under node --test (see node-test:node-test-conventions), test writing conventions (see vitest:vitest-test-conventions), PHP TDD (see phpunit:php-tdd-workflow).","https:\u002F\u002Fgithub.com\u002FFabienSalles\u002Fclaude-marketplace\u002Fblob\u002Fmain\u002Fplugins\u002Fvitest\u002Fskills\u002Fvitest-tdd-workflow\u002FSKILL.md",[],[37,36,80,21,81,38,82,35,83,84,33,85,32,30,29,86,28,27,87,88],"tdd workflow","vitest tdd workflow","dev","examples","fix","red-green-refactor","green","feature","app",{"skillNo":90,"name":91,"nameZh":6,"description":92,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":93,"categories":94,"keywords":95,"publishedAt":39},"01M6DW2RGMQE10D8C5Z5MA2RMY","ts-refactoring","ACTIVATE when refactoring TypeScript code. ACTIVATE for 'refactor', 'extract', 'redesign', 'simplify', or 'clean up' in a TypeScript \u002F Node \u002F NestJS context. This skill provides TS-specific examples for the cross-language refactoring rules defined in craft:refactoring-principles. DO NOT use for: writing new features from scratch, general OOP patterns (see ts-oop).","https:\u002F\u002Fgithub.com\u002FFabienSalles\u002Fclaude-marketplace\u002Fblob\u002Fmain\u002Fplugins\u002Ftypescript\u002Fskills\u002Fts-refactoring\u002FSKILL.md",[],[96,97,38,98,99,83,100,101,102,103,104,33,105,106,107,23,108,30,29,109],"refactoring","ts refactoring","typescript","code","refactor","simplify","Rules","node","redesign","up","general","clean","craft","patterns",{"skillNo":111,"name":112,"nameZh":6,"description":113,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":114,"categories":115,"keywords":116,"publishedAt":39},"01M6DW2MHYXNBBVYEGB058Y48J","ts-ports-adapters","ACTIVATE when a TypeScript codebase with no dependency-injection container has to declare a port and wire its adapter — a repository, a clock, an id generator, an event dispatcher the domain depends on. ACTIVATE for 'port', 'adapter', 'SPI', 'dependency inversion' or 'composition root' in a codebase that wires its dependencies by hand. Covers: the port as a type of functions in the domain layer, the adapter as an object literal annotated with it, the handler that takes its dependencies first and its data second, the composition root in the infrastructure layer, and the in-memory stub that substitutes for the adapter in a unit test. DO NOT use for: NestJS, or any container-based DI with decorators and tokens (see nest-ddd-conventions), aggregate operations and smart constructors (see ddd-ts-fp), the Result type itself (see ts-functional).","https:\u002F\u002Fgithub.com\u002FFabienSalles\u002Fclaude-marketplace\u002Fblob\u002Fmain\u002Fplugins\u002Ftypescript\u002Fskills\u002Fts-ports-adapters\u002FSKILL.md",[],[117,118,119,20,120,121,33,122,123,23,124,30,29,125,126,127,128,129,130,131],"ports","ts ports adapters","memory","ddd","Composition","container","functions","Literal","dependency-injection","domain","tokens","as","type","id","adapter",{"skillNo":133,"name":134,"nameZh":6,"description":135,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":136,"categories":137,"keywords":138,"publishedAt":39},"01M6DW2GRXZFYT05HEDB26C9B8","ts-oop","ACTIVATE when designing TypeScript classes, and the value objects or collections modelled as classes, or when the user asks about object design, encapsulation, Tell Don't Ask, or Symbol.iterator. Provides TS-specific examples for the cross-language OOP rules defined in craft:oop-principles, plus TS-specific patterns (Symbol.iterator, branded types for primitive identifiers). DO NOT use for: a value object or an aggregate modelled as an immutable record rather than a class (see ddd-ts-fp), refactoring methodology (see ts-refactoring).","https:\u002F\u002Fgithub.com\u002FFabienSalles\u002Fclaude-marketplace\u002Fblob\u002Fmain\u002Fplugins\u002Ftypescript\u002Fskills\u002Fts-oop\u002FSKILL.md",[],[139,140,141,98,120,83,142,143,96,102,144,33,145,108,30,29,146,147,148,128],"oop","ts oop","design","methodology","immutable","ask","refactoring methodology","objects","record","collections",{"skillNo":150,"name":151,"nameZh":6,"description":152,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":153,"categories":154,"keywords":155,"publishedAt":39},"01M6DW2D26XG5MJMTP9MSE43S2","ts-layer-boundaries","ACTIVATE when wiring a Worker entry point, a Router, a controller, or a domain event consumer in a TypeScript CQRS codebase, or when deciding where a port belongs. ACTIVATE for 'composition root', 'layer boundary', 'ESLint zones', 'domain must not import infrastructure'. Covers: the *Worker.ts composition root, the curried consumer, Router wiring of command endpoints, the five-gesture controller, the domain-to-infrastructure import boundary enforced by ESLint, infrastructure-only ports, in-memory doubles for every port, the read-can-reach-write asymmetry, and read endpoints going through a domain handler. DO NOT use for: the port's own shape and adapter binding (see ts-ports-adapters), the Result type (see ts-functional), domain event structure (see ts-ddd-events).","https:\u002F\u002Fgithub.com\u002FFabienSalles\u002Fclaude-marketplace\u002Fblob\u002Fmain\u002Fplugins\u002Ftypescript\u002Fskills\u002Fts-layer-boundaries\u002FSKILL.md",[],[156,119,120,157,158,121,117,33,159,160,161,30,29,162,126,163,164,129,131,165],"ts layer boundaries","controller","boundary","router","only","endpoints","structure","cqrs","worker","import",{"skillNo":167,"name":168,"nameZh":6,"description":169,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":170,"categories":171,"keywords":172,"publishedAt":39},"01M6DW29A825FAK3T1VGKTK3EM","ts-functional","ACTIVATE when writing functional-style TypeScript: pipe, compose, currying, Result types, railway-oriented programming, or AsyncResult. ACTIVATE for 'pipe', 'Result type', 'railway', 'functional', 'chain'. Covers: type-safe pipe implementation, currying patterns, generic Result type, railway-oriented error handling, AsyncResult for async pipelines. DO NOT use for: DDD aggregate modeling (see ddd-ts-fp), OOP patterns (see ts-oop), imperative code.","https:\u002F\u002Fgithub.com\u002FFabienSalles\u002Fclaude-marketplace\u002Fblob\u002Fmain\u002Fplugins\u002Ftypescript\u002Fskills\u002Fts-functional\u002FSKILL.md",[],[173,38,174,98,99,175,120,176,33,177,178,179,30,29,109,180,181,129,182,183],"ts functional","safe","error handling","programming","compose","implementation","async","pipe","modeling","style","chain"]