genkit-tools-testing
Installation
SKILL.md
Genkit Tools Testing Guide
1. Test Structure & Philosophy
- One behavior per test: Keep each
it(...)block focused on a single behavior followingarrange -> act -> assertwith a clear, behavior-driven description. Split tests that assert multiple independent functions or behaviors. - Prefer single structured assertions: Use one
toMatchObject/toEqualassertion on structured outputs instead of scattering field-by-fieldexpect(...)calls on the same object, and avoid asserting incidental ordering (e.g.Object.keys(...)insertion order) when order isn't part of the contract. - Parameterized variations (
it.each): Useit.eachwhen verifying the same behavior across multiple input variations and a table meaningfully reduces duplication:- Prefer separate
it(...)blocks when cases exercise distinct behaviors or branches, need different setup or assertions, or are simple enough thatit.eachadds more indirection than clarity. - Prefer named-object rows (
it.each([{ name: '...', ..., expected: ... }])with$namein the test title) over positional tuples whenever rows have 3+ fields or complex objects; simple 2-element[input, expected]scalar tuples are fine for concise mappings.
- Prefer separate
- Test our logic, not library internals: Do not write unit tests that merely verify third-party library or Zod schema validation behavior. Focus on our domain logic, transformations, edge-case fallbacks, and error handling.
2. File Layout & Shared Fixtures
- Mirror
src/intests/: Place tests intests/<subpath>/<name>.test.ts(kebab-case) mirroringsrc/<subpath>/<name>.ts. - Keep fixtures separate from test suites: Put reusable test builders and fixture constants in dedicated
testing/mock_data.tshelpers rather than duplicating large inline objects across*.test.tsfiles.