2.9 KiB
ADDED Requirements
Requirement: Test files import test-runner primitives via the canonical wrapper
Every *.test.ts / *.test.tsx file in the monorepo SHALL import test-runner primitives (describe, it, test, expect, expectTypeOf, vi, inject, beforeAll, beforeEach, afterAll, afterEach, and the runner-neutral mock helpers fn, spy, stub, mock, fakeClock, restoreMocks, restoreTimers) from @suaveplan/testing/runner. Direct imports from vitest or bun:test are forbidden EXCEPT in the testing-infrastructure packages that author or extend the wrapper.
The exempt allowlist is defined by package.json#name and SHALL be exactly:
@suaveplan/testing@suaveplan/testing-dom@suaveplan/testing-e2e@suaveplan/testing-integration@suaveplan/testing-integration-step-ca
Adding a package to the allowlist requires its own OpenSpec change with justification (the package must author runner-internal machinery — extending fixtures or production-side @suaveplan/testing consumers do NOT qualify).
Scenario: Non-exempt package uses canonical wrapper
- WHEN any test file under
packages/*/<pkg>/src/**/*.test.{ts,tsx}is inspected, where<pkg>is not in the exempt allowlist - THEN every import of
describe,it,test,expect,expectTypeOf,vi,inject,beforeAll,beforeEach,afterAll, orafterEachMUST resolve to afrom "@suaveplan/testing/runner"source AND the file MUST contain zerofrom "vitest"/from "bun:test"import statements
Scenario: Exempt testing-infra package may import vitest / bun:test directly
- WHEN a test or implementation file inside
@suaveplan/testing,@suaveplan/testing-dom,@suaveplan/testing-e2e,@suaveplan/testing-integration, or@suaveplan/testing-integration-step-cais inspected - THEN the file MAY import directly from
vitestand/orbun:test(these packages author or extend the runner wrapper itself)
Scenario: CI gate blocks regression
- WHEN the
lint:test-runner-importsscript (scripts/lint/check-test-runner-imports.ts) runs in CI on any commit - THEN it walks every
packages/*/*/package.json, skips packages whosenameis in the exempt allowlist, greps the package'ssrc/**/*.{ts,tsx}forfrom ['"]vitest['"]andfrom ['"]bun:test['"], and exits non-zero with a per-file error list when any matches are found
Scenario: Migration prerequisite
- WHEN a package is migrated from upstream
../suaveplan/into the genesis monorepo (perenterprise-package-migrationworkflow) - THEN every
from "vitest"/from "bun:test"import in the source MUST be rewritten tofrom "@suaveplan/testing/runner"as part of the migration commit, NOT as a follow-up — mirroring theexport *→ explicit named-exports rule from §6a
Verified by: scripts/lint/check-test-runner-imports.ts MUST pass on the full monorepo as a precondition for merging any change to main.