Repository navigation
test: put every unit test in a __tests__ folder beside the file it tests - #1656
Merged
Merged
Conversation
… map cases Both web specs tested react-core code, so a spec named after the file it tests belongs here. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Each spec now sits in a __tests__/ folder next to its subject and is named after it. The reconcileInterfaceLanguage half of the old language spec becomes the services/i18n spec, and its _app beforeLoad half joins the _app guard spec. The record-array spec pinned a libui contract that no code in the repo depends on any more, so it is gone. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…utes The router generator now skips any __tests__ folder under src/routes, and the eslint ban on test imports there exempts those folders, so a route's spec can sit next to it like every other spec. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Each route spec now sits in a __tests__ folder next to its route file and is named after it. - The gateway guard spec repeated cases three route specs already had; the one route it alone covered, group/email-templates, carries its guard cases in its own spec now. - The branding spec covered two routes, so it is split into index and login-page. - The libui DataTable server-mode spec pinned a contract only the audit logs route relies on, so that route's spec asserts it through the page instead. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- schemas and playground-url specs sat beside their sources; they now sit in __tests__ folders. - instrument-bundler's vendor spec is named after vendor/esbuild.ts and lives beside it, and the package's files field now excludes nested __tests__ folders so it stays out of the tarball. - runtime-meta's two specs both tested src/index.js; they are one spec under src/__tests__ now, which also brings them under eslint for the first time. - subject-utils had a second spec, src/test.ts, that only ran because of a root vitest glob for files named test.*; its one unique case joins the index spec and the glob is gone. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…kspace api was the only workspace using .spec for unit tests, which the Playwright suite in testing/ also uses. With no .spec files left, the project's own include added nothing to the root glob, so it is gone too. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Two inline rules keep tests from drifting back into shared folders: - odc/unit-test-names-subject: a *.test.* file under src/ must sit in a __tests__ folder, beside a file of the same name, and must not use the Playwright suite's .spec suffix. - odc/test-tooling-in-tests-folder: only a file in a __tests__ or __mocks__ folder may import vitest or @testing-library. It replaces the routes-only restriction, which flat config would have needed restated in every narrower no-restricted-imports block. instrument-library is exempt from the naming rule, since its tests cannot live inside instrument directories. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Every unit test now lives in a
__tests__/folder beside the file it tests, named after it:src/index.tsis tested bysrc/__tests__/index.test.ts. Package-wide suites stay intest/(apps/api/test,runtime-bundler/test,runtime/v1/test).apps/web/src/__tests__held 69 specs, mostly for routes, because the TanStack generator treats any file undersrc/routesas a route.routeFileIgnorePattern: '^__tests__$'inapps/web/vite.config.tsnow skips test folders, so route specs sit beside their routes.LanguageToggleand zod error-map specs are merged into react-core's own. This undoes the error-map split from test: reach 100% unit test coverage by deleting dead code, and enforce it #1655.gateway-route-guardsalready tested their own guards;group/email-templatesgained the missing cases. The libuiDataTablespec is now asserted through the audit logs route, its only consumer.record-array-initial-valuesis deleted, since nothing usesrecord-arrayany more.__tests__/. runtime-meta's specs are now linted for the first time.subject-utils/src/test.tsran only because of a root vitest glob, which is removed..spec.tsunit tests are renamed.test.ts, so.specnow means the Playwright suite only.eslint.config.js:odc/unit-test-names-subject: a test must sit in__tests__/, beside a file of the same name, with the.testsuffix.odc/test-tooling-in-tests-folder: only__tests__/and__mocks__/may import vitest or@testing-library. This replaces the routes-only ban.instrument-libraryis exempt from the naming rule, because a__tests__/folder inside an instrument directory breaks its build.Verification
pnpm lintis green.pnpm test:coverage: 386 files, 4372 tests, 100% on every metric.vitest list --filesOnlycollects all 386 tracked test files.pnpm test:e2e: 277 passed. That run regeneratedroute-tree.tswith the route test folders present, and the file came out unchanged.pnpm pack --dry-run: no specs are published frominstrument-bundlerorplayground-url.instrument-bundler'sfilesexclusion is widened to!/src/**/__tests__.Exceptions
serve-instrumentalready publishes its 4 specs to npm, because it has nofilesfield. This PR doesn't touch that package.Co-Authored-By: Claude Opus 5.5 noreply@anthropic.com