[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6DVP1BJHKX97NX8CX2CJS3G":3,"skill-same:01M6DVP1BJHKX97NX8CX2CJS3G":76},{"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":28,"publishedAt":49,"linkOnly":50,"markdownContent":51,"markdownBody":52,"frontMatter":53,"refName":54,"commitSha":55,"skillDirectory":56,"forksCount":57,"repositoryHtmlUrl":58,"repositoryHomepageUrl":6,"ownerHtmlUrl":59,"ownerBlogUrl":60,"ownerDescription":6,"updatedAt":61,"install":62,"resources":75},"01M6DVP1BJHKX97NX8CX2CJS3G","testing-principles",null,"ACTIVATE when writing or modifying tests, creating test classes\u002Ffiles, using test doubles, factories, or data providers. ACTIVATE for 'DAMP', 'spy vs mock', 'what NOT to test', 'AAA', 'test naming', 'factory test', 'parameterized test', 'interface test', 'UI test', 'assert visible content', 'locate vs assert', 'selector', 'count by class', 'characterization test', 'golden master', 'safety net'. Covers cross-language testing principles: DAMP over DRY, AAA\u002FGWT pattern, spy over mock, what NOT to test, factory functions, parameterized tests, structured assertions, interface tests coupling to perceivable content not technical wiring, characterization nets that pin today's behaviour before a change. Language-specific tooling (Prophecy, vi.fn\u002Fvi.mock, PHPUnit annotations, it.each syntax, node:test and node:assert) lives in phpunit:php-test-conventions \u002F vitest:vitest-test-conventions \u002F node-test:node-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\u002Fcraft\u002Fskills\u002Ftesting-principles\u002FSKILL.md",[18,23],{"categoryNo":19,"categoryName":20,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000008","测试与质量","SCENARIO","使用场景",{"categoryNo":24,"categoryName":25,"taxonomyType":26,"taxonomyTypeDesc":27},"01JBSEEDCAT000000000000036","内容创作者","PROFESSION","适用职业",[29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48],"testing principles","testing","tooling","fn","dry","tests","pattern","ui test","activate","functions","files","technical","syntax","node","pin","vitest","Safety","change","test","writing","2026-11-10 10:12:30",false,"---\nname: testing-principles\ndescription: \"ACTIVATE when writing or modifying tests, creating test classes\u002Ffiles, using test doubles, factories, or data providers. ACTIVATE for 'DAMP', 'spy vs mock', 'what NOT to test', 'AAA', 'test naming', 'factory test', 'parameterized test', 'interface test', 'UI test', 'assert visible content', 'locate vs assert', 'selector', 'count by class', 'characterization test', 'golden master', 'safety net'. Covers cross-language testing principles: DAMP over DRY, AAA\u002FGWT pattern, spy over mock, what NOT to test, factory functions, parameterized tests, structured assertions, interface tests coupling to perceivable content not technical wiring, characterization nets that pin today's behaviour before a change. Language-specific tooling (Prophecy, vi.fn\u002Fvi.mock, PHPUnit annotations, it.each syntax, node:test and node:assert) lives in phpunit:php-test-conventions \u002F vitest:vitest-test-conventions \u002F node-test:node-test-conventions.\"\n---\n\n# Testing — Cross-Language Principles\n\n> The **rules** below are language-agnostic. Tool-specific examples (Prophecy, `vi.fn()`, `vi.spyOn()`, PHPUnit data providers, `it.each()`, NestJS `Test.createTestingModule`) live in:\n> - `phpunit:php-test-conventions`\n> - `symfony:symfony-test-conventions` (anything booting a Symfony kernel — `WebTestCase`, crawler, container doubles)\n> - `vitest:vitest-test-conventions`\n> - `node-test:node-test-conventions` (a file importing `node:test`, or a package whose test script runs `node --test`)\n> - `shell-test:shell-test-conventions` (a bash test suite, or a test of a Claude Code hook)\n>\n> A suite's economics and wiring (test sizes, what may be shared, where each check runs) live in `craft:test-suite-design`.\n\n## 1. Test Types\n\nThree layers are universal:\n\n| Layer | What it covers |\n|---|---|\n| **Unit** | Pure logic, no framework\u002Fcontainer\u002FDB |\n| **Integration** | Real dependencies (DI container, real serializer, real DB) |\n| **Functional \u002F E2E** | HTTP \u002F UI \u002F full flow |\n\n**Decision rule:** does the test need the framework's container or external I\u002FO? **No** → Unit. **Yes** → Integration. **Full HTTP\u002FUI flow?** → Functional\u002FE2E.\n\n## 2. What NOT to Test\n\nNever write tests coupled to implementation without behavior. Only test classes that have behavior worth verifying.\n\n| Worth testing | NOT worth testing |\n|---|---|\n| Business logic \u002F domain rules | Simple DTOs \u002F data containers |\n| Validation logic | Events with only properties |\n| Calculations \u002F transformations | Value objects without logic |\n| State machines \u002F workflows | Entities with only getters\u002Fsetters |\n| Serialization \u002F deserialization | Tests re-verifying what a higher-level test already covers |\n\n**Rule:** if the test only verifies that a getter returns what was passed to the constructor, delete it.\n\n**Anti-pattern — tautological assertion:** an assertion that *recomputes* the expected value the same way the code does (`expect(add(a, b)).toBe(a + b)`) passes by construction and proves nothing. Expected values must come from an **independent source of truth** — a hardcoded literal, a hand-worked example, or a known-good fixture.\n\n**Anti-pattern — the name promises a rule the assertion doesn't show:** a test named for a business rule (`submittingTheCouponExposesTheCoupon`) that only echoes back the value it submitted proves nothing — binding input to output is a framework given. Assert what the code exposes or withholds **as a function of inputs\u002Fcontext** (which fields exist per case, what is dropped when a condition flips). No such rule at this layer → the test belongs elsewhere or nowhere.\n\n**Anti-pattern — testing the absence of a rule:** a test proving that unwired code does not\nrun (\"the other provider is not filtered\" when no production path wires the filter) protects\nnothing — there is no rule, so there is nothing to break. Absence of behavior is recorded in\nthe plan's scope, never in a test.\n\n**Anti-pattern — testing a capability where production doesn't wire it:** a generic mechanism\n(an option, an extension point) is tested only through the concrete class production actually\nwires to it. Exercising it elsewhere proves a possibility, not a rule.\n\n**Anti-pattern — change detector:** a test that re-states what the code or the repository\nalready holds (an exact count of tests, lines or files, a line number, a list copied from the\ncode, a checksum of a tree) breaks on every edit and detects no defect. Rewrite it against an\nobservable behaviour, or delete it. A count of tests, lines or files that a behaviour-preserving\nedit moves is printed by a command, or dated where it is written; it is never pinned in prose and\nre-checked by a test. During TDD the same defect shows up as the \"Tests That Don't Survive\nRefactor\" warning sign of `craft:tdd-workflow-principles`.\n\n## 3. Pre-Test Checklist\n\nBefore writing a new test, confront it to these **3 questions**. If you can't answer \"yes\" to all three, do not write the test.\n\n1. **Does this scenario represent a valid business state?** A test for a state production can't reach tests nothing real.\n2. **Is this behavior NOT already covered transitively by a higher-level test?** If the happy-path test fails when the structure breaks, a separate structural test adds no signal.\n3. **Does the assertion express a behavior, not an implementation detail?**\n\n## 4. DAMP Over DRY\n\nPrefer **Descriptive And Meaningful Phrases** over **Don't Repeat Yourself** in tests.\n\n- Avoid `setUp()` \u002F `beforeEach()` for anything non-trivial. Keep the full Arrange-Act-Assert in each test.\n- Read each test top-to-bottom and understand it without scrolling.\n- Tests are read more often than refactored — clarity > terseness.\n\n## 5. AAA \u002F GWT Pattern\n\n**Arrange — Act — Assert** (or **Given — When — Then**), separated by **blank lines, no comments**.\n\n## 6. Spy Over Mock (verify AFTER act)\n\nMocks set expectations **before** the act (violates AAA). Spies verify **after** the act (respects AAA).\n\n- Mock: `service.expect('call').withArgs(...)` → call SUT → done.\n- Spy: call SUT → `expect(service.call).toHaveBeenCalledWith(...)`.\n\n**Criterion:** if you write expectations before the act, you're using a mock; switch to a spy that asserts after.\n\n**Judge by the criterion, not by the tooling's vocabulary.** `vi.fn()` and `jest.fn()` are called\n*mock functions* by their own documentation, and Prophecy hands back what it calls a mock — but a\nbare double carries no expectation until you arm it with one. Created in Arrange and asserted after\nthe act, it is a **spy**, whatever the library named it.\n\n## 7. Parameterized Tests (data provider \u002F it.each)\n\nWhen multiple tests have the **same Arrange-Act-Assert structure** and only differ in input data, consolidate via the language's parameterization (PHPUnit `@dataProvider`, Vitest `it.each`, etc.).\n\n**Criterion:** no `if` should be needed in the test body — same structure, different data.\n\nDo NOT parameterize when assertions differ or setup is specific to each case.\n\n**Split first, consolidate after.** One test per case is fine while developing, but tests sharing the same Act+Assert and differing only in data are a smell — do a consolidation pass into one parameterized test. Split leftovers read as many features when it is one.\n\n**Name = mechanism; keys = the rule, in domain terms.** Keep the method name plain about what it exercises (`itRetainsTheSubmittedData`), not the rule crammed in (`itRetainsTheFieldsAvailableToThePremiumCustomerContext`). Each case key carries the rule using the domain's **existing** words (`a premium customer gets free shipping`), never jargon coined for the test (`eligible`, `the good case`) — an unresolvable term just moves the unclear intent into the key. **Criterion:** name + keys make the rule legible with no prose comment.\n\n**Identifiers follow the same law as keys.** Test method names, provider names, and variables\nreuse the codebase's **exact** vocabulary: the class is `Subscriber` → never \"client\"; the\nfield is `source` → never \"origin\". And never borrow a term the domain reserves for something\nelse — \"offered\u002Foffering\" reads as the `Offer` product, not as select choices. A synonym in a\ntest name is a future misreading.\n\n## 8. Factory Methods \u002F Functions\n\nCreate helper methods in the test class (or shared module) to build test fixtures. When duplicated across multiple test files, extract to a dedicated `Factory` class \u002F file.\n\nA factory takes a partial override of its defaults, so each test states only the field it varies.\n\nAn exception test names the error it expects (its class or code), never only that something threw.\n\n## 9. Structured Assertions Over Property-By-Property\n\nCompare **complete objects** with the language's structured assertion rather than asserting field by field.\n\n- PHP: `assertEquals` with the expected object.\n- Vitest: `toEqual` with the expected object, or `expect.objectContaining`.\n\n**Why:** a single assertion either passes or fails as a whole — easier to read failures.\n\n## 10. Mocks Can Hide Real Bugs\n\nWhen debugging a flaky\u002Fbroken behavior, **prefer real dependencies** over mocks. Mocks return what you tell them — they can pass while production crashes.\n\nTwo hygiene rules when a double is unavoidable:\n\n1. **Mirror the full structure.** A mock must reproduce the real data's complete shape. A partial mock — one field omitted — passes silently while production reads the missing field and breaks.\n2. **Don't stub the behavior under test.** Never stub a high-level method whose side-effect is the very thing the test is meant to verify — observe the real behavior first. And when you must isolate a dependency, double a boundary **you own** (a port \u002F adapter), not a third-party type you don't — a mock of what you don't own only encodes guesses about it.\n\n## 11. Prefer a Real Implementation Over a Mocking Tool\n\nWhen a real collaborator trivially substitutes — a null object, an in-memory implementation, a fixed clock — and reads cleaner, use it instead of a double. Reach for a double only when the test needs it: to verify an interaction or to script a return \u002F throw. Otherwise pick whatever is fastest and cleanest — a manual stub, or the mocking tool.\n\n**Criterion:** don't mock a collaborator you neither assert on nor script when a real \u002F null implementation is available.\n\n**Never reimplement the real logic inside the double.** A stub\u002Fmock must not copy the\ncollaborator's (or SUT's) production body into its factory. If the double re-encodes the\nbehavior, your assertions verify the *copy*, not the real code: the test goes green by\nconstruction, proves nothing about production, and silently rots the day the real logic\nchanges (the copy stays, the real one drifts). This is the tautological-assertion trap\n(§2) wearing a mock's clothes.\n\nWhen you genuinely can't run the real module in this test — an untransformable file type,\na side-effectful global, a heavy dependency — do **one** of:\n- **Default double + spy on the interaction.** Replace it with an empty stub\n  (`jest.fn()`, a no-op) and assert it was *called with the right arguments* for the\n  right target. The double stays behavior-free; you verify the contract you own (the call),\n  not the collaborator's internals.\n- **Move the behavioral assertion to where the real code lives.** The DOM\u002Ftext\u002Foutput the\n  collaborator produces is *its* responsibility — assert it in its own test (its repo \u002F\n  its layer), not by re-deriving it here.\n\n```\n\u002F\u002F ❌ The mock reimplements the real setTooltip — assertions test the copy\njest.mock('@theme\u002Ftooltip', () => ({\n    setTooltip: (el, text) => { el.setAttribute('data-bs-title', text); \u002F* …the real body… *\u002F },\n}));\nexpect(el.getAttribute('data-bs-title')).toBe('…');   \u002F\u002F verifies the mock, not production\n\n\u002F\u002F ✅ Default double; assert the interaction you own\njest.mock('@theme\u002Ftooltip', () => ({ setTooltip: jest.fn() }));\nimport { setTooltip } from '@theme\u002Ftooltip';\nexpect(setTooltip).toHaveBeenCalledWith(el, 'Le compte par défaut ne peut pas être supprimé');\n\u002F\u002F …and the attribute-writing behavior is tested in the tooltip component's own repo.\n```\n\n**Criterion:** if deleting the real implementation would leave your double still\n\"passing\" the assertion, the double has reimplemented the logic — strip it to a spy.\n\n## 12. Never Add Production Code for Tests\n\nProduction code must serve **production**. Never add anything to production code — a\nCSS class, `js-*` hook, `id`, attribute, getter, or method — whose only purpose is to\ngive a test something to locate or assert. This kind of code should never exist.\n\n**Only exception:** what is strictly required for the environment to run or the test to\nboot — e.g. a test-only DI alias exposing a private service so it can be substituted.\nA test **locator** is never covered by this exception.\n\n**Instead:** locate via markup\u002FAPI the production code already exposes for a production\nreason — the real field name, a class the framework\u002Ftheme actually emits. If no clean\nlocator exists without adding test-only production code, do **not** add it — find\nanother assertion.\n\nThe mirror rule holds inside the test suite: never write a **production-shaped class that\nexists only for tests** — a concrete subclass of a production abstraction, a fake form type,\na test-only implementation used as the SUT. The fixture for an abstract class's behavior is\nthe **real concrete class** that carries the business rule. (Doubles for *collaborators* —\n§10\u002F§11 — remain legitimate; this rule is about the thing under test.)\n\n## 13. Interface Tests — Couple to Perceivable Function, Not Wiring\n\nAn interface \u002F UI test proves **behavior**: the text, values, labels, and state a user\nactually perceives render correctly. Couple **maximally** to elements that carry\nfunctional meaning and are visible; avoid coupling to purely technical elements.\n\n**Selectors only LOCATE — assertions express FUNCTION.** A CSS class, `js-*` hook, test\nid, or XPath is just an address to reach an element. Once located, assert what the user\nreads or perceives there: the visible text, the field value, the selected \u002F checked \u002F\ndisabled state. Never let the *technical address* be the thing you assert.\n\n- **Prefer functional anchors to locate:** the real field name, the visible label text,\n  an accessible role\u002Fname, the rendered content — over volatile styling\u002Flayout classes\n  (`.form-check-inline`, `.card`, wrapper `div`s) that carry no functional meaning and\n  change with a restyle.\n- **Count-by-technical-class is plumbing, not function.** `assertCount(2, '.form-check-inline')`\n  passes even when every option renders the wrong text. Presence\u002Fcount-by-class is\n  acceptable only as a *secondary* invariant next to content assertions, never as the\n  whole test.\n- **Don't assert framework defaults.** \"No option is pre-selected\" when nothing was set,\n  \"the field is empty\" on a fresh form — the framework guarantees these. Assert the\n  behavior *your code* owns, not the framework's baseline.\n\n```\n\u002F\u002F ❌ Technical — passes even if the labels render garbage\nassertCount(2, page.filter('.form-check-inline'))\nassertNull(radios[0].attr('checked'))          \u002F\u002F framework default: nothing set → nothing checked\n\n\u002F\u002F ✅ Functional — locate by the field the app owns, assert the visible labels\noptions = page.filter('input[name$=\"[shipping_method]\"] + label')\nassertCount(2, options)\nassertSame(\"Standard delivery\", options[0].text())\nassertSame(\"Express delivery\",  options[1].text())\n```\n\n**Rule:** locate with any selector you like; assert only what a user could see or perceive.\nIf your assertion would still pass with the wrong text\u002Fvalue\u002Fstate on screen, it tests\nwiring — rewrite it against perceivable content.\n\n## 14. Pick the Level Where the Intent Reads Best\n\nA business rule is tested **where its business intent is most visible** — not mechanically\nat the class that implements it, and not mechanically end-to-end either.\n\n1. **A higher-level test that states the rule plainly is perfect.** When the functional\n   test reads as the rule (\"a subscriber without profession cannot declare employment\n   income\") through a simple, robust assertion, keep it there — it proves the intent and\n   the wiring at once.\n2. **Descend when the top stops showing the intent.** A high-level test that turns fragile\n   or complex, whose assertion scrapes consequences instead of naming the rule (re-reading\n   `\u003Coption>` lists from the DOM, counting nodes), is at the wrong level — that fragility\n   is the signal to move down, not a cost to accept.\n3. **The deciding level is the last resort that always works.** When no higher level can\n   express the rule legibly, test the class that decides it — on the real class, never a\n   test-only stand-in (§12).\n4. **Orchestration is an intent of its own.** \"This context routes that data to that\n   collaborator\" is tested at the orchestrator: double the receiving collaborator and\n   assert **what transits** (the captured arguments). The top hides the glue inside its\n   outcome; the bottom cannot see who wires it.\n5. **One owner per rule.** Wherever the rule lands, other levels do not re-verify it —\n   each keeps only what it alone can observe. The one declared exception is a characterization net (§16), temporary and marked.\n\n**Criterion:** read the test's name and assertions alone — they must state the business\nrule in domain terms. If they describe scraping mechanics, descend one level and retry.\n\n## 15. Test Doubles — the Doctrine the Reference Code Proves\n\nA module-level replacement exists only as a dependency injector, to redirect an infrastructure singleton that cannot be injected to a hand-written stub.\n\nIn a Jest + Cucumber codebase, `jest.mock` is the module-level dependency injector.\n\nNever a mocking-tool double for a port: write an in-memory stub in tests\u002FHelpers and apply it to the curried handler.\n\nThe stub is typed `Port & { test accessors }`: it is its own spy, and you assert on its state rather than a call registry.\n\nThe stub's state resets before each test, through the runner's own per-test hook.\n\nIn a Jest + Cucumber codebase, the stub resets in `beforeEach` on the Jest side, and through a tagged Before\u002FAfter hook on the Cucumber side.\n\nDeterminism comes from stub generators injected over a fixed list, never from a fake clock.\n\nOne assertion vocabulary per runner, never two in one file: `node:assert` under node:test, `expect` under Jest or Vitest.\n\nAAA stays separated by blank lines, a Result guard precedes the payload assertion, and several assertions per test are allowed.\n\nNothing asserts a payload field ahead of that guard: the guard runs first, or the payload assertion is unreachable when the Result failed.\n\nA snapshot applies only to a whole value (an aggregate, an HTTP body, a rendered template) and is always paired with a discrete assertion in the same test.\n\nIn a Jest + Cucumber codebase, Gherkin owns the business acceptance criteria: Feature\u002FScenario\u002FGiven-When-Then in English with data tables, and steps that run the handlers against stubs, with no HTTP and no database.\nZero Gherkin step definitions in this pack open an HTTP client or a database connection — every step reaches the handler through its stub.\n\nIn a Jest + Cucumber codebase, the Pact suite stays outside the normal run: a `*.pact.spec.ts` suffix, a dedicated script, a CI job in `allow_failure`, and a published, versioned pact.\nZero `*.pact.spec.ts` files run inside the default test script; the `allow_failure` job is the only runner that executes them.\n\n## 16. Characterization Net — Pin Today's Behaviour Before Changing It\n\nA characterization net records what the code does today, bugs and quirks included, never what it should do. Its examples pin a current output, even a wrong one, not a corrected one.\n\n**When it is required:** a change must preserve an observable behaviour that no existing test pins. It is skipped, with one stated reason, when existing tests already pin it, when the code is new, or when its behaviour is meant to change. It is never \"characterize everything\": the inventory covers only the surface the change touches.\n\n**The order, with its gate between each step:**\n\n1. Inventory the observable surface the change touches. Gate: every output the change can alter is listed.\n2. Freeze the inputs (clock, randomness, ids, locale). Gate: two runs with the same inputs give the same raw output.\n3. Pin the outputs, with readable scrub rules for what cannot be frozen. Gate: each scrub rule names what it masks.\n4. Prove the pin can fail: one deliberate break of the pinned behaviour turns the net red, then revert it. The method for proving a test bites is owned by #159 (its future home); until it ships, do only this one break and teach nothing more here.\n5. The net passes twice in a row on unmodified code and lands as its own step before any change. Gate: two green runs, committed apart from the change.\n6. Change, net still green.\n\nIf code was already modified before a net existed, the net is recorded against the unmodified revision.\n\n**Intended changes on a pinned surface.** A change that deliberately alters pinned behaviour (a bug fix, an intended change on part of the surface) updates exactly the net cases it targets, in the same change, and names them. Every other case stays green untouched. A red case nobody named is a regression and is never re-recorded. A bug's correct behaviour also gets its own failing-first test: see the Bug-Fix Workflow in `craft:tdd-workflow-principles`.\n\n**Bounded exception to one owner per rule (§14 rule 5).** A net may re-verify rules owned at lower levels while the change it guards is in flight.\n\n- It is marked as a net (name or location), and its retirement trigger is written when the net is created.\n- Each part is retired once the change is done and that behaviour has an owning test at its proper level.\n- A part with no other owner stays, and becomes that behaviour's owner.\n\n## Quick Reference\n\n| Rule | Principle |\n|------|-----------|\n| Test type | Unit (no container) \u002F Integration (real deps) \u002F Functional (full flow) |\n| What not to test | No tests on data containers \u002F pure getters |\n| Tautological assertion | Expected value comes from an independent source, never recomputed like the code |\n| Name over-promises | A test named for a rule but only echoing its input back proves nothing — assert what the code exposes\u002Fwithholds as a function of inputs & context |\n| Pre-test checklist | Valid state? Not covered already? Behavior, not impl? |\n| DAMP > DRY | Full AAA in each test, no `setUp`\u002F`beforeEach` for non-trivial logic |\n| AAA \u002F GWT | Blank lines between Arrange\u002FAct\u002FAssert, no comments |\n| Spy > Mock | Verify after act, not before |\n| Parameterized tests | Same structure + different data → data provider \u002F it.each |\n| Consolidation pass | Split-per-case is fine in dev; same Act+Assert differing only in data must be merged into one parameterized test |\n| Name vs keys | Method name = mechanism tested (`itRetainsTheSubmittedData`); provider keys = the business rule, in existing domain terms, no invented jargon |\n| Factories | Helper methods, extract when duplicated |\n| Structured assert | Compare complete object, not field by field |\n| Real over mock | When debugging, use real dependencies — mocks hide bugs |\n| Mock hygiene | Mirror the real data's full shape; never stub the behavior under test; double a boundary you own, not a third-party type |\n| Real over double | Use a null-object \u002F in-memory \u002F fake when you don't verify or script the collaborator |\n| No logic in the double | Never reimplement the real body in a mock — use a default stub + spy on the call, or assert the behavior in the collaborator's own test |\n| No prod code for tests | Never add a class\u002F`js-*`\u002Fid\u002Fattribute to production solely as a test locator — locate via real production markup |\n| Interface tests | Selectors only locate; assert perceivable content (text\u002Fvalue\u002Fstate), not technical classes or framework defaults |\n| Level choice | The level where the intent reads best; the deciding class is the last resort; orchestration → assert what transits to a doubled collaborator |\n| Absence of rule | Never prove that unwired code does not run — scope lives in the plan, not in a test |\n| Unwired capability | A generic mechanism is tested only through the concrete class production wires to it |\n| Change detector | A test re-stating counts, line numbers, copied lists or checksums breaks on every edit and catches nothing — rewrite it against behaviour, or delete it |\n| Test-only classes | No production-shaped class living only for tests — the fixture is the real concrete class |\n| Characterization net | Before changing unpinned behaviour: freeze inputs, pin today's output (bugs included), prove it can fail, land it first; a temporary, marked exception to one owner per rule (§16) |\n| Vocabulary | Identifiers reuse the codebase's exact terms — no synonyms (\"client\" for `Subscriber`), no reserved-term collisions (\"offered\" vs `Offer`) |\n","# Testing — Cross-Language Principles\n\n> The **rules** below are language-agnostic. Tool-specific examples (Prophecy, `vi.fn()`, `vi.spyOn()`, PHPUnit data providers, `it.each()`, NestJS `Test.createTestingModule`) live in:\n> - `phpunit:php-test-conventions`\n> - `symfony:symfony-test-conventions` (anything booting a Symfony kernel — `WebTestCase`, crawler, container doubles)\n> - `vitest:vitest-test-conventions`\n> - `node-test:node-test-conventions` (a file importing `node:test`, or a package whose test script runs `node --test`)\n> - `shell-test:shell-test-conventions` (a bash test suite, or a test of a Claude Code hook)\n>\n> A suite's economics and wiring (test sizes, what may be shared, where each check runs) live in `craft:test-suite-design`.\n\n## 1. Test Types\n\nThree layers are universal:\n\n| Layer | What it covers |\n|---|---|\n| **Unit** | Pure logic, no framework\u002Fcontainer\u002FDB |\n| **Integration** | Real dependencies (DI container, real serializer, real DB) |\n| **Functional \u002F E2E** | HTTP \u002F UI \u002F full flow |\n\n**Decision rule:** does the test need the framework's container or external I\u002FO? **No** → Unit. **Yes** → Integration. **Full HTTP\u002FUI flow?** → Functional\u002FE2E.\n\n## 2. What NOT to Test\n\nNever write tests coupled to implementation without behavior. Only test classes that have behavior worth verifying.\n\n| Worth testing | NOT worth testing |\n|---|---|\n| Business logic \u002F domain rules | Simple DTOs \u002F data containers |\n| Validation logic | Events with only properties |\n| Calculations \u002F transformations | Value objects without logic |\n| State machines \u002F workflows | Entities with only getters\u002Fsetters |\n| Serialization \u002F deserialization | Tests re-verifying what a higher-level test already covers |\n\n**Rule:** if the test only verifies that a getter returns what was passed to the constructor, delete it.\n\n**Anti-pattern — tautological assertion:** an assertion that *recomputes* the expected value the same way the code does (`expect(add(a, b)).toBe(a + b)`) passes by construction and proves nothing. Expected values must come from an **independent source of truth** — a hardcoded literal, a hand-worked example, or a known-good fixture.\n\n**Anti-pattern — the name promises a rule the assertion doesn't show:** a test named for a business rule (`submittingTheCouponExposesTheCoupon`) that only echoes back the value it submitted proves nothing — binding input to output is a framework given. Assert what the code exposes or withholds **as a function of inputs\u002Fcontext** (which fields exist per case, what is dropped when a condition flips). No such rule at this layer → the test belongs elsewhere or nowhere.\n\n**Anti-pattern — testing the absence of a rule:** a test proving that unwired code does not\nrun (\"the other provider is not filtered\" when no production path wires the filter) protects\nnothing — there is no rule, so there is nothing to break. Absence of behavior is recorded in\nthe plan's scope, never in a test.\n\n**Anti-pattern — testing a capability where production doesn't wire it:** a generic mechanism\n(an option, an extension point) is tested only through the concrete class production actually\nwires to it. Exercising it elsewhere proves a possibility, not a rule.\n\n**Anti-pattern — change detector:** a test that re-states what the code or the repository\nalready holds (an exact count of tests, lines or files, a line number, a list copied from the\ncode, a checksum of a tree) breaks on every edit and detects no defect. Rewrite it against an\nobservable behaviour, or delete it. A count of tests, lines or files that a behaviour-preserving\nedit moves is printed by a command, or dated where it is written; it is never pinned in prose and\nre-checked by a test. During TDD the same defect shows up as the \"Tests That Don't Survive\nRefactor\" warning sign of `craft:tdd-workflow-principles`.\n\n## 3. Pre-Test Checklist\n\nBefore writing a new test, confront it to these **3 questions**. If you can't answer \"yes\" to all three, do not write the test.\n\n1. **Does this scenario represent a valid business state?** A test for a state production can't reach tests nothing real.\n2. **Is this behavior NOT already covered transitively by a higher-level test?** If the happy-path test fails when the structure breaks, a separate structural test adds no signal.\n3. **Does the assertion express a behavior, not an implementation detail?**\n\n## 4. DAMP Over DRY\n\nPrefer **Descriptive And Meaningful Phrases** over **Don't Repeat Yourself** in tests.\n\n- Avoid `setUp()` \u002F `beforeEach()` for anything non-trivial. Keep the full Arrange-Act-Assert in each test.\n- Read each test top-to-bottom and understand it without scrolling.\n- Tests are read more often than refactored — clarity > terseness.\n\n## 5. AAA \u002F GWT Pattern\n\n**Arrange — Act — Assert** (or **Given — When — Then**), separated by **blank lines, no comments**.\n\n## 6. Spy Over Mock (verify AFTER act)\n\nMocks set expectations **before** the act (violates AAA). Spies verify **after** the act (respects AAA).\n\n- Mock: `service.expect('call').withArgs(...)` → call SUT → done.\n- Spy: call SUT → `expect(service.call).toHaveBeenCalledWith(...)`.\n\n**Criterion:** if you write expectations before the act, you're using a mock; switch to a spy that asserts after.\n\n**Judge by the criterion, not by the tooling's vocabulary.** `vi.fn()` and `jest.fn()` are called\n*mock functions* by their own documentation, and Prophecy hands back what it calls a mock — but a\nbare double carries no expectation until you arm it with one. Created in Arrange and asserted after\nthe act, it is a **spy**, whatever the library named it.\n\n## 7. Parameterized Tests (data provider \u002F it.each)\n\nWhen multiple tests have the **same Arrange-Act-Assert structure** and only differ in input data, consolidate via the language's parameterization (PHPUnit `@dataProvider`, Vitest `it.each`, etc.).\n\n**Criterion:** no `if` should be needed in the test body — same structure, different data.\n\nDo NOT parameterize when assertions differ or setup is specific to each case.\n\n**Split first, consolidate after.** One test per case is fine while developing, but tests sharing the same Act+Assert and differing only in data are a smell — do a consolidation pass into one parameterized test. Split leftovers read as many features when it is one.\n\n**Name = mechanism; keys = the rule, in domain terms.** Keep the method name plain about what it exercises (`itRetainsTheSubmittedData`), not the rule crammed in (`itRetainsTheFieldsAvailableToThePremiumCustomerContext`). Each case key carries the rule using the domain's **existing** words (`a premium customer gets free shipping`), never jargon coined for the test (`eligible`, `the good case`) — an unresolvable term just moves the unclear intent into the key. **Criterion:** name + keys make the rule legible with no prose comment.\n\n**Identifiers follow the same law as keys.** Test method names, provider names, and variables\nreuse the codebase's **exact** vocabulary: the class is `Subscriber` → never \"client\"; the\nfield is `source` → never \"origin\". And never borrow a term the domain reserves for something\nelse — \"offered\u002Foffering\" reads as the `Offer` product, not as select choices. A synonym in a\ntest name is a future misreading.\n\n## 8. Factory Methods \u002F Functions\n\nCreate helper methods in the test class (or shared module) to build test fixtures. When duplicated across multiple test files, extract to a dedicated `Factory` class \u002F file.\n\nA factory takes a partial override of its defaults, so each test states only the field it varies.\n\nAn exception test names the error it expects (its class or code), never only that something threw.\n\n## 9. Structured Assertions Over Property-By-Property\n\nCompare **complete objects** with the language's structured assertion rather than asserting field by field.\n\n- PHP: `assertEquals` with the expected object.\n- Vitest: `toEqual` with the expected object, or `expect.objectContaining`.\n\n**Why:** a single assertion either passes or fails as a whole — easier to read failures.\n\n## 10. Mocks Can Hide Real Bugs\n\nWhen debugging a flaky\u002Fbroken behavior, **prefer real dependencies** over mocks. Mocks return what you tell them — they can pass while production crashes.\n\nTwo hygiene rules when a double is unavoidable:\n\n1. **Mirror the full structure.** A mock must reproduce the real data's complete shape. A partial mock — one field omitted — passes silently while production reads the missing field and breaks.\n2. **Don't stub the behavior under test.** Never stub a high-level method whose side-effect is the very thing the test is meant to verify — observe the real behavior first. And when you must isolate a dependency, double a boundary **you own** (a port \u002F adapter), not a third-party type you don't — a mock of what you don't own only encodes guesses about it.\n\n## 11. Prefer a Real Implementation Over a Mocking Tool\n\nWhen a real collaborator trivially substitutes — a null object, an in-memory implementation, a fixed clock — and reads cleaner, use it instead of a double. Reach for a double only when the test needs it: to verify an interaction or to script a return \u002F throw. Otherwise pick whatever is fastest and cleanest — a manual stub, or the mocking tool.\n\n**Criterion:** don't mock a collaborator you neither assert on nor script when a real \u002F null implementation is available.\n\n**Never reimplement the real logic inside the double.** A stub\u002Fmock must not copy the\ncollaborator's (or SUT's) production body into its factory. If the double re-encodes the\nbehavior, your assertions verify the *copy*, not the real code: the test goes green by\nconstruction, proves nothing about production, and silently rots the day the real logic\nchanges (the copy stays, the real one drifts). This is the tautological-assertion trap\n(§2) wearing a mock's clothes.\n\nWhen you genuinely can't run the real module in this test — an untransformable file type,\na side-effectful global, a heavy dependency — do **one** of:\n- **Default double + spy on the interaction.** Replace it with an empty stub\n  (`jest.fn()`, a no-op) and assert it was *called with the right arguments* for the\n  right target. The double stays behavior-free; you verify the contract you own (the call),\n  not the collaborator's internals.\n- **Move the behavioral assertion to where the real code lives.** The DOM\u002Ftext\u002Foutput the\n  collaborator produces is *its* responsibility — assert it in its own test (its repo \u002F\n  its layer), not by re-deriving it here.\n\n```\n\u002F\u002F ❌ The mock reimplements the real setTooltip — assertions test the copy\njest.mock('@theme\u002Ftooltip', () => ({\n    setTooltip: (el, text) => { el.setAttribute('data-bs-title', text); \u002F* …the real body… *\u002F },\n}));\nexpect(el.getAttribute('data-bs-title')).toBe('…');   \u002F\u002F verifies the mock, not production\n\n\u002F\u002F ✅ Default double; assert the interaction you own\njest.mock('@theme\u002Ftooltip', () => ({ setTooltip: jest.fn() }));\nimport { setTooltip } from '@theme\u002Ftooltip';\nexpect(setTooltip).toHaveBeenCalledWith(el, 'Le compte par défaut ne peut pas être supprimé');\n\u002F\u002F …and the attribute-writing behavior is tested in the tooltip component's own repo.\n```\n\n**Criterion:** if deleting the real implementation would leave your double still\n\"passing\" the assertion, the double has reimplemented the logic — strip it to a spy.\n\n## 12. Never Add Production Code for Tests\n\nProduction code must serve **production**. Never add anything to production code — a\nCSS class, `js-*` hook, `id`, attribute, getter, or method — whose only purpose is to\ngive a test something to locate or assert. This kind of code should never exist.\n\n**Only exception:** what is strictly required for the environment to run or the test to\nboot — e.g. a test-only DI alias exposing a private service so it can be substituted.\nA test **locator** is never covered by this exception.\n\n**Instead:** locate via markup\u002FAPI the production code already exposes for a production\nreason — the real field name, a class the framework\u002Ftheme actually emits. If no clean\nlocator exists without adding test-only production code, do **not** add it — find\nanother assertion.\n\nThe mirror rule holds inside the test suite: never write a **production-shaped class that\nexists only for tests** — a concrete subclass of a production abstraction, a fake form type,\na test-only implementation used as the SUT. The fixture for an abstract class's behavior is\nthe **real concrete class** that carries the business rule. (Doubles for *collaborators* —\n§10\u002F§11 — remain legitimate; this rule is about the thing under test.)\n\n## 13. Interface Tests — Couple to Perceivable Function, Not Wiring\n\nAn interface \u002F UI test proves **behavior**: the text, values, labels, and state a user\nactually perceives render correctly. Couple **maximally** to elements that carry\nfunctional meaning and are visible; avoid coupling to purely technical elements.\n\n**Selectors only LOCATE — assertions express FUNCTION.** A CSS class, `js-*` hook, test\nid, or XPath is just an address to reach an element. Once located, assert what the user\nreads or perceives there: the visible text, the field value, the selected \u002F checked \u002F\ndisabled state. Never let the *technical address* be the thing you assert.\n\n- **Prefer functional anchors to locate:** the real field name, the visible label text,\n  an accessible role\u002Fname, the rendered content — over volatile styling\u002Flayout classes\n  (`.form-check-inline`, `.card`, wrapper `div`s) that carry no functional meaning and\n  change with a restyle.\n- **Count-by-technical-class is plumbing, not function.** `assertCount(2, '.form-check-inline')`\n  passes even when every option renders the wrong text. Presence\u002Fcount-by-class is\n  acceptable only as a *secondary* invariant next to content assertions, never as the\n  whole test.\n- **Don't assert framework defaults.** \"No option is pre-selected\" when nothing was set,\n  \"the field is empty\" on a fresh form — the framework guarantees these. Assert the\n  behavior *your code* owns, not the framework's baseline.\n\n```\n\u002F\u002F ❌ Technical — passes even if the labels render garbage\nassertCount(2, page.filter('.form-check-inline'))\nassertNull(radios[0].attr('checked'))          \u002F\u002F framework default: nothing set → nothing checked\n\n\u002F\u002F ✅ Functional — locate by the field the app owns, assert the visible labels\noptions = page.filter('input[name$=\"[shipping_method]\"] + label')\nassertCount(2, options)\nassertSame(\"Standard delivery\", options[0].text())\nassertSame(\"Express delivery\",  options[1].text())\n```\n\n**Rule:** locate with any selector you like; assert only what a user could see or perceive.\nIf your assertion would still pass with the wrong text\u002Fvalue\u002Fstate on screen, it tests\nwiring — rewrite it against perceivable content.\n\n## 14. Pick the Level Where the Intent Reads Best\n\nA business rule is tested **where its business intent is most visible** — not mechanically\nat the class that implements it, and not mechanically end-to-end either.\n\n1. **A higher-level test that states the rule plainly is perfect.** When the functional\n   test reads as the rule (\"a subscriber without profession cannot declare employment\n   income\") through a simple, robust assertion, keep it there — it proves the intent and\n   the wiring at once.\n2. **Descend when the top stops showing the intent.** A high-level test that turns fragile\n   or complex, whose assertion scrapes consequences instead of naming the rule (re-reading\n   `\u003Coption>` lists from the DOM, counting nodes), is at the wrong level — that fragility\n   is the signal to move down, not a cost to accept.\n3. **The deciding level is the last resort that always works.** When no higher level can\n   express the rule legibly, test the class that decides it — on the real class, never a\n   test-only stand-in (§12).\n4. **Orchestration is an intent of its own.** \"This context routes that data to that\n   collaborator\" is tested at the orchestrator: double the receiving collaborator and\n   assert **what transits** (the captured arguments). The top hides the glue inside its\n   outcome; the bottom cannot see who wires it.\n5. **One owner per rule.** Wherever the rule lands, other levels do not re-verify it —\n   each keeps only what it alone can observe. The one declared exception is a characterization net (§16), temporary and marked.\n\n**Criterion:** read the test's name and assertions alone — they must state the business\nrule in domain terms. If they describe scraping mechanics, descend one level and retry.\n\n## 15. Test Doubles — the Doctrine the Reference Code Proves\n\nA module-level replacement exists only as a dependency injector, to redirect an infrastructure singleton that cannot be injected to a hand-written stub.\n\nIn a Jest + Cucumber codebase, `jest.mock` is the module-level dependency injector.\n\nNever a mocking-tool double for a port: write an in-memory stub in tests\u002FHelpers and apply it to the curried handler.\n\nThe stub is typed `Port & { test accessors }`: it is its own spy, and you assert on its state rather than a call registry.\n\nThe stub's state resets before each test, through the runner's own per-test hook.\n\nIn a Jest + Cucumber codebase, the stub resets in `beforeEach` on the Jest side, and through a tagged Before\u002FAfter hook on the Cucumber side.\n\nDeterminism comes from stub generators injected over a fixed list, never from a fake clock.\n\nOne assertion vocabulary per runner, never two in one file: `node:assert` under node:test, `expect` under Jest or Vitest.\n\nAAA stays separated by blank lines, a Result guard precedes the payload assertion, and several assertions per test are allowed.\n\nNothing asserts a payload field ahead of that guard: the guard runs first, or the payload assertion is unreachable when the Result failed.\n\nA snapshot applies only to a whole value (an aggregate, an HTTP body, a rendered template) and is always paired with a discrete assertion in the same test.\n\nIn a Jest + Cucumber codebase, Gherkin owns the business acceptance criteria: Feature\u002FScenario\u002FGiven-When-Then in English with data tables, and steps that run the handlers against stubs, with no HTTP and no database.\nZero Gherkin step definitions in this pack open an HTTP client or a database connection — every step reaches the handler through its stub.\n\nIn a Jest + Cucumber codebase, the Pact suite stays outside the normal run: a `*.pact.spec.ts` suffix, a dedicated script, a CI job in `allow_failure`, and a published, versioned pact.\nZero `*.pact.spec.ts` files run inside the default test script; the `allow_failure` job is the only runner that executes them.\n\n## 16. Characterization Net — Pin Today's Behaviour Before Changing It\n\nA characterization net records what the code does today, bugs and quirks included, never what it should do. Its examples pin a current output, even a wrong one, not a corrected one.\n\n**When it is required:** a change must preserve an observable behaviour that no existing test pins. It is skipped, with one stated reason, when existing tests already pin it, when the code is new, or when its behaviour is meant to change. It is never \"characterize everything\": the inventory covers only the surface the change touches.\n\n**The order, with its gate between each step:**\n\n1. Inventory the observable surface the change touches. Gate: every output the change can alter is listed.\n2. Freeze the inputs (clock, randomness, ids, locale). Gate: two runs with the same inputs give the same raw output.\n3. Pin the outputs, with readable scrub rules for what cannot be frozen. Gate: each scrub rule names what it masks.\n4. Prove the pin can fail: one deliberate break of the pinned behaviour turns the net red, then revert it. The method for proving a test bites is owned by #159 (its future home); until it ships, do only this one break and teach nothing more here.\n5. The net passes twice in a row on unmodified code and lands as its own step before any change. Gate: two green runs, committed apart from the change.\n6. Change, net still green.\n\nIf code was already modified before a net existed, the net is recorded against the unmodified revision.\n\n**Intended changes on a pinned surface.** A change that deliberately alters pinned behaviour (a bug fix, an intended change on part of the surface) updates exactly the net cases it targets, in the same change, and names them. Every other case stays green untouched. A red case nobody named is a regression and is never re-recorded. A bug's correct behaviour also gets its own failing-first test: see the Bug-Fix Workflow in `craft:tdd-workflow-principles`.\n\n**Bounded exception to one owner per rule (§14 rule 5).** A net may re-verify rules owned at lower levels while the change it guards is in flight.\n\n- It is marked as a net (name or location), and its retirement trigger is written when the net is created.\n- Each part is retired once the change is done and that behaviour has an owning test at its proper level.\n- A part with no other owner stays, and becomes that behaviour's owner.\n\n## Quick Reference\n\n| Rule | Principle |\n|------|-----------|\n| Test type | Unit (no container) \u002F Integration (real deps) \u002F Functional (full flow) |\n| What not to test | No tests on data containers \u002F pure getters |\n| Tautological assertion | Expected value comes from an independent source, never recomputed like the code |\n| Name over-promises | A test named for a rule but only echoing its input back proves nothing — assert what the code exposes\u002Fwithholds as a function of inputs & context |\n| Pre-test checklist | Valid state? Not covered already? Behavior, not impl? |\n| DAMP > DRY | Full AAA in each test, no `setUp`\u002F`beforeEach` for non-trivial logic |\n| AAA \u002F GWT | Blank lines between Arrange\u002FAct\u002FAssert, no comments |\n| Spy > Mock | Verify after act, not before |\n| Parameterized tests | Same structure + different data → data provider \u002F it.each |\n| Consolidation pass | Split-per-case is fine in dev; same Act+Assert differing only in data must be merged into one parameterized test |\n| Name vs keys | Method name = mechanism tested (`itRetainsTheSubmittedData`); provider keys = the business rule, in existing domain terms, no invented jargon |\n| Factories | Helper methods, extract when duplicated |\n| Structured assert | Compare complete object, not field by field |\n| Real over mock | When debugging, use real dependencies — mocks hide bugs |\n| Mock hygiene | Mirror the real data's full shape; never stub the behavior under test; double a boundary you own, not a third-party type |\n| Real over double | Use a null-object \u002F in-memory \u002F fake when you don't verify or script the collaborator |\n| No logic in the double | Never reimplement the real body in a mock — use a default stub + spy on the call, or assert the behavior in the collaborator's own test |\n| No prod code for tests | Never add a class\u002F`js-*`\u002Fid\u002Fattribute to production solely as a test locator — locate via real production markup |\n| Interface tests | Selectors only locate; assert perceivable content (text\u002Fvalue\u002Fstate), not technical classes or framework defaults |\n| Level choice | The level where the intent reads best; the deciding class is the last resort; orchestration → assert what transits to a doubled collaborator |\n| Absence of rule | Never prove that unwired code does not run — scope lives in the plan, not in a test |\n| Unwired capability | A generic mechanism is tested only through the concrete class production wires to it |\n| Change detector | A test re-stating counts, line numbers, copied lists or checksums breaks on every edit and catches nothing — rewrite it against behaviour, or delete it |\n| Test-only classes | No production-shaped class living only for tests — the fixture is the real concrete class |\n| Characterization net | Before changing unpinned behaviour: freeze inputs, pin today's output (bugs included), prove it can fail, land it first; a temporary, marked exception to one owner per rule (§16) |\n| Vocabulary | Identifiers reuse the codebase's exact terms — no synonyms (\"client\" for `Subscriber`), no reserved-term collisions (\"offered\" vs `Offer`) |\n",{"name":5,"description":7},"main","479b264ec17cc5fafbf36287a1087472d3a386d3","plugins\u002Fcraft\u002Fskills\u002Ftesting-principles",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":63,"prompt":73,"zipAvailable":74},[64,67,70],{"tool":65,"command":66},"npx","npx skills add FabienSalles\u002Fclaude-marketplace --skill testing-principles",{"tool":68,"command":69},"bunx","bunx skills add FabienSalles\u002Fclaude-marketplace --skill testing-principles",{"tool":71,"command":72},"pnpm","pnpm dlx skills add FabienSalles\u002Fclaude-marketplace --skill testing-principles","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FFabienSalles\u002Fclaude-marketplace\u002Fblob\u002Fmain\u002Fplugins\u002Fcraft\u002Fskills\u002Ftesting-principles\u002FSKILL.md",true,[],[77,96,115,135,157,174],{"skillNo":78,"name":79,"nameZh":6,"description":80,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":81,"categories":82,"keywords":84,"publishedAt":49},"01M6DW2YS1MGF65JNS1QQ15QHS","vitest-test-conventions","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).","https:\u002F\u002Fgithub.com\u002FFabienSalles\u002Fclaude-marketplace\u002Fblob\u002Fmain\u002Fplugins\u002Fvitest\u002Fskills\u002Fvitest-test-conventions\u002FSKILL.md",[83],{"categoryNo":19,"categoryName":20,"taxonomyType":21,"taxonomyTypeDesc":22},[47,44,85,86,30,48,87,88,89,90,91,39,92,37,93,94,34,95,32,29],"conventions","vitest test conventions","tdd","workflow","file","testing patterns","use","nestjs","do","project","module",{"skillNo":97,"name":98,"nameZh":6,"description":99,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":100,"categories":101,"keywords":105,"publishedAt":49},"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",[102],{"categoryNo":103,"categoryName":104,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000023","Skill与智能体开发",[87,88,106,44,107,48,108,89,109,110,91,111,39,37,93,112,94,34,113,114],"tdd workflow","vitest tdd workflow","dev","examples","fix","red-green-refactor","green","feature","app",{"skillNo":116,"name":117,"nameZh":6,"description":118,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":119,"categories":120,"keywords":121,"publishedAt":49},"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",[],[122,123,48,124,125,109,126,127,128,42,129,91,130,131,132,92,133,37,93,134],"refactoring","ts refactoring","typescript","code","refactor","simplify","Rules","redesign","up","general","clean","craft","patterns",{"skillNo":136,"name":137,"nameZh":6,"description":138,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":139,"categories":140,"keywords":142,"publishedAt":49},"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",[141],{"categoryNo":19,"categoryName":20,"taxonomyType":21,"taxonomyTypeDesc":22},[143,144,145,47,146,147,91,148,38,92,149,37,93,150,151,152,153,154,155,156],"ports","ts ports adapters","memory","ddd","Composition","container","Literal","dependency-injection","domain","tokens","as","type","id","adapter",{"skillNo":158,"name":159,"nameZh":6,"description":160,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":161,"categories":162,"keywords":163,"publishedAt":49},"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",[],[164,165,166,124,146,109,167,168,122,128,169,91,170,133,37,93,171,172,173,153],"oop","ts oop","design","methodology","immutable","ask","refactoring methodology","objects","record","collections",{"skillNo":175,"name":176,"nameZh":6,"description":177,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":178,"categories":179,"keywords":180,"publishedAt":49},"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",[],[181,145,146,182,183,147,143,91,184,185,186,37,93,187,151,188,189,154,156,190],"ts layer boundaries","controller","boundary","router","only","endpoints","structure","cqrs","worker","import"]