Skip to content

perf(test): give the unit lane a per-edit budget it is actually under #285

Closed

Description

@sydevs-bot

Summary

Every src/**/*.{ts,tsx} edit pays the whole unit lane: .claude/hooks/unit-test.mjs runs
pnpm test:run as a PostToolUse hook. Measured 2026-10-11 on 4 cores that is ~28s over 1698
tests in 133 files. docs/testing.md asked for "under ~5s" and nothing has been under it since the
jsdom specs arrived, so the lane currently has no stated bound and nothing owns its growth.

Approach

  • The cost is measured and lopsided. 113 node-only files take ~16s; the 25 jsdom files add
    ~12s on top (docs/testing.md, "The jsdom exception"). List them with
    grep -rl '@vitest-environment jsdom' src/. The jsdom opt-in is where a reduction is available.
  • Options to weigh, none chosen here:
    • A second vitest project (vitest.config.ts) splitting node from jsdom, with the hook running
      only the lane that can cover the edited file.
    • Related-file selection in .claude/hooks/unit-test.mjs — vitest related <file> — so an edit
      pays its own specs rather than the suite. ⚠ Nine specs walk all of src/ and so are related
      to every file (see the sibling ticket on the shared source walker), which caps what this buys.
    • Converting jsdom specs back to SSR where docs/testing.md's precedent list does not justify a
      DOM. Each conversion must keep the assertion non-vacuous — that file's own closed-portal
      section is the trap.
  • Then state one number in docs/testing.md and have the hook note cite it, instead of the
    figure-restating this ticket replaced. docs/testing.md's hook note links here today.

⚠ The hook reports failures as non-blocking context, so a slower lane fails nothing and shows up
only as latency on every edit. That is why it needs a stated budget rather than a feeling.

Acceptance criteria

  • docs/testing.md states one lane budget, and the per-edit hook note cites that budget.
  • The command the hook runs completes inside the stated budget on a 4-core machine.
  • Any spec moved off jsdom still fails when its defect is reintroduced at the causing site.

Verification checklist

  • time pnpm test:run, three runs on 4 cores; report the median against the stated budget
  • grep -rl '@vitest-environment jsdom' src/ | wc -l before and after
  • pnpm lint && pnpm typecheck && pnpm test:run green

Notes

Found addressing the review on #284, whose docs/testing.md thread asked for a bound or a ticket
owning the cost. #284 cites this ticket rather than restating a figure nothing checks.

Activity

  1. added theissue type on Oct 11, 2026
  2. added
    proposal
    on Oct 11, 2026
  3. Ardnived commented on Oct 13, 2026

    @Ardnived
    Contributor

    @sydevs-bot implement

  4. added
    bot:working
    and removed
    proposal
    on Oct 13, 2026
  5. moved this from Proposed to Approved in SYDevelopers Technical Roadmapon Oct 13, 2026
  6. sydevs-bot commented on Oct 13, 2026

    @sydevs-bot
    ContributorAuthor

    🤖 no session running

    recent dispatches
    • 02:45Z implement · attempt 1 · session · done
    • 02:45Z implement · attempt 1 · session

    Written by the sydevs dispatcher. Sessions never edit this comment.

  7. removed
    bot:working
    on Oct 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Fields

    Priority

    Low

    Hold Until

    None yet

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions