mirror of
https://github.com/duckietm/Nitro-V3.git
synced 2026-06-19 15:06:20 +00:00
tests: co-locate every Vitest suite next to its subject under src/
Eliminate the parallel `tests/` tree. Each `*.test.ts` / `*.test.tsx` now sits in the same directory as the module it covers, mirroring its filename (`Foo.ts` ↔ `Foo.test.ts`). The renderer-SDK mock used by component / hook tests moves to `src/__mocks__/nitro-renderer.ts` and the Vitest setup file becomes `src/test-setup.ts` — both still wired through `vitest.config.mts` exactly as before, only the paths changed. All 13 suites + 178/178 cases still pass. The production build is unaffected: rollup only follows imports from `src/index.tsx` and never crosses into `.test.ts` files, so test code is naturally tree-shaken out of the bundle. `yarn build` output is byte-for-byte the same on the user-facing chunks. tsconfig drops the now-redundant `tests` include entry. CLAUDE.md 'Layout convention' replaces the old `tests/` row with three rows documenting the new co-located convention, the `__mocks__/` directory and the `test-setup.ts` entry; ARCHITECTURE.md picks up the same update. The 'DO NOT CHANGE' qualifier on the layout is preserved — this rewrite IS the change, decided deliberately to make tests a first-class part of the source tree rather than a sibling project.
This commit is contained in:
+7
-8
@@ -6,23 +6,22 @@ import { resolve } from 'path';
|
||||
* dev/build config wires up the renderer SDK via filesystem aliases that
|
||||
* point at sibling working trees (`../renderer`, `../Nitro_Render_V3`).
|
||||
*
|
||||
* Test files were originally written against pure modules (helpers,
|
||||
* stores) that don't pull in the renderer. We now also support
|
||||
* component-level tests by aliasing `@nitrots/nitro-renderer` to a
|
||||
* hand-written stub at `tests/mocks/renderer-mock.ts` so jsdom doesn't
|
||||
* try to evaluate Pixi + the full message parser/composer registry.
|
||||
* Tests live next to their subject under `src/` (`foo.ts` + `foo.test.ts`).
|
||||
* The renderer SDK is aliased to a hand-written stub at
|
||||
* `src/__mocks__/nitro-renderer.ts` so jsdom doesn't try to evaluate
|
||||
* Pixi + the full message parser/composer registry at import time.
|
||||
*/
|
||||
export default defineConfig({
|
||||
test: {
|
||||
environment: 'jsdom',
|
||||
globals: false,
|
||||
include: [ 'tests/**/*.test.ts', 'tests/**/*.test.tsx' ],
|
||||
setupFiles: [ './tests/setup.ts' ],
|
||||
include: [ 'src/**/*.test.ts', 'src/**/*.test.tsx' ],
|
||||
setupFiles: [ './src/test-setup.ts' ],
|
||||
css: false
|
||||
},
|
||||
resolve: {
|
||||
alias: {
|
||||
'@nitrots/nitro-renderer': resolve(__dirname, 'tests/mocks/renderer-mock.ts'),
|
||||
'@nitrots/nitro-renderer': resolve(__dirname, 'src/__mocks__/nitro-renderer.ts'),
|
||||
'@': resolve(__dirname, 'src')
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user