You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- vitest, vitest-ansi-serializer, any vitest plugins
95
+
- jest, @jest/types, jest transforms and presets
83
96
- Any TypeScript runners: tsx, ts-node, esbuild-register
84
97
85
98
## Step 7: Move Tests to Colocated Pattern
86
99
87
-
If tests are in __tests__/ or test/ directories, move them next to source:
88
-
-__tests__/schema.test.ts → src/schema.test.ts (next to src/schema.ts)
100
+
If tests are in **tests**/ or test/ directories, move them next to source:
101
+
102
+
-**tests**/schema.test.ts → src/schema.test.ts (next to src/schema.ts)
89
103
- Use .test.ts for runtime, .test-d.ts for type-level
90
104
91
-
## Step 8: Verify
105
+
## Step 8: Adopt Test Utilities
106
+
107
+
Replace manual mock setups with `createMocks` from `@bomb.sh/tools/test-utils`. It handles env stubbing, stream mocking, and auto-cleanup via `onTestFinished`.
Vitest test runner with colocated test files and a filesystem fixture utility.
22
+
Vitest test runner with colocated test files, filesystem fixtures, and mock utilities.
22
23
23
24
## Setup
24
25
26
+
`bsh test` auto-loads its own vitest config — no `vitest.config.ts` needed in your project. The bundled config excludes `dist/`, sets `FORCE_COLOR=1`, and registers `vitest-ansi-serializer` for snapshot tests with ANSI output.
27
+
25
28
Run the full test suite:
26
29
27
30
```sh
@@ -136,6 +139,59 @@ The `symlink` helper creates a symbolic link:
136
139
}
137
140
```
138
141
142
+
### createMocks
143
+
144
+
Creates a mock test environment with streams and env vars. Cleanup is automatic via `onTestFinished` — no `beforeAll`/`afterAll` needed.
Files ending in `.test-d.ts` run compile-time type assertions using `expectTypeOf` from vitest. No runtime code executes — these tests verify that types resolve correctly.
0 commit comments