Skip to content

wr-tdd: hook stem-match strictness fails variant-named tests to pair with their source module (needs canonical <stem>.test.js) #398

Description

@tompahoward

Description

@windyroad/tdd's PreToolUse hook tdd_find_test_for_impl requires a canonical <stem>.test.js file to exist for a source module. When a module's tests are ALL variant-named (src/foo.<variant>.test.js) with no src/foo.test.js, the hook associates NO test and blocks TDD-gated edits to src/foo.js, even though the variant tests exist and pass under vitest. Co-location (same-dir) is necessary but not sufficient — the stem-match is additionally strict. Distinct from the closed same-dir / __tests__ / test-mirror location issue (#123): this is stem-canonicality, not test location.

Symptoms

  • A source module whose tests are all variant-named, with no canonical src/foo.test.js, is associated with NO test — tdd_find_test_for_impl returns empty.
  • TDD-gated edits hit the enforce-edit deny (no tests written for this file yet. TDD state is IDLE) despite passing variant tests.
  • vitest still discovers and runs the variant tests; only the hook's per-module association fails.

Workaround

Keep a canonical <stem>.test.js per module (the hook's ${STEM}.test.* glob matches it); additional edge-case suites use <stem>.<variant>.test.js. When a module has only variant suites, rename the primary suite to the canonical name (git mv src/foo.success.test.js src/foo.test.js).

Affected plugin / component

@windyroad/tddtdd_find_test_for_impl in hooks/lib/tdd-gate.sh (stem-match strictness).

Frequency

Per source module whose paired tests are all variant-named with no canonical <stem>.test.js.

Versions

  • Local plugin: @windyroad/tdd (not detected — marketplace install)
  • Upstream package: @windyroad/tdd (not detected)
  • Claude Code CLI: 2.1.219
  • Node: v24.16.0
  • OS: Darwin 25.3.0 arm64

Evidence

Fix shape: relax tdd_find_test_for_impl's glob to match ${STEM}.*.test.* (variant-named) in addition to ${STEM}.test.*, so any same-stem test file in the module's directory associates.

Cross-reference

Reported from https://github.com/voder-ai/dry-aged-deps — tracked locally as problem ticket P020 in docs/problems/.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions