Superseded by 0022: every test file now sits in a
__tests__/ directory.Context
An earlier rule asked for a roottests/ directory mirroring src/. Five layouts then ignored it, because nothing
checked it. The rule that survives is the one a contributor follows by default: a test sits next to the thing it tests.
Decision
- A unit test lives beside its subject:
src/**/__tests__/<name>.test.ts, or<name>.test.tsnext to the file. The name is the subject’s name plus.test. - No root
tests/directory in any member and notest/ortesting/directories. - App end-to-end suites live in their app (
apps/<app>/e2e), not in a shared workspace. - Cross-cutting fixtures and doubles are an explicit
testingentry of the package that owns the contract, not a shared folder. - Tests need zero secrets. Provider fakes replace credentials; a test that needs a real credential is a design finding (0009).
- A green
pnpm verifyproves less than it seems. What it does not prove (runtime behaviour on a device, visual and right-to-left correctness, behaviour against a real provider) is stated in/standards/testing.
Consequences
- Moving a file moves its test with it.
- Vitest globs are the same in every member and come from the vitest preset.
Enforcement
Planned: a validator rule that fails a member with a roottests/ directory and any test file outside src/**/__tests__ or beside its subject.
Today AGENTS.md states the rule and pnpm test runs what exists; nothing rejects a misplaced test.
Supersedes and sources
Supersedes: none. Sources: basaltadr/0034-test-file-placement (and the strategy part of 0019-testing-strategy, whose root-tests/ mirror is rejected here).