Setup Tests
Use this skill to bootstrap or repair the test harness for a TypeScript + Effect repository.
When To Use
- •The repo has no test runner configured.
- •
bun run testorbun run test:coveragedoes not exist. - •
@effect/vitestis missing for Effect-first tests. - •Coverage settings are missing or below required policy.
Only run this setup when the user asks for test-harness installation or repair.
Prerequisites
- •Package manager is Bun.
- •TypeScript project already exists (
tsconfig.jsonpresent). - •User approved dependency and config changes.
Setup Steps
- •Install required dev dependencies.
bash
bun add -d vitest @effect/vitest @vitest/coverage-v8
- •Ensure test scripts exist in
package.json.
json
{
"scripts": {
"test": "vitest run",
"test:watch": "vitest",
"test:coverage": "vitest run --coverage"
}
}
- •Add
vitest.config.tswith explicit include/exclude and coverage policy.
typescript
import { defineConfig } from "vitest/config";
export default defineConfig({
test: {
include: ["src/**/*.test.ts"],
exclude: ["src/env.ts"],
coverage: {
provider: "v8",
reporter: ["text", "html"],
thresholds: {
lines: 100,
functions: 100,
branches: 100,
statements: 100,
},
},
},
});
- •Validate scaffold-level conventions.
- •Co-locate tests as
src/**/*.test.ts. - •Use
@effect/vitestfor Effect-centric tests. - •Use
vifromvitestfor mocks and env stubs. - •Keep quality-gate scripts available:
test,test:watch,test:coverage.
- •Add a baseline test only if no tests exist yet.
typescript
import { describe, expect, it } from "@effect/vitest";
import { Effect } from "effect";
describe("smoke", () => {
it.effect("runs Effect test harness", () =>
Effect.gen(function* () {
expect(1 + 1).toBe(2);
}),
);
});
- •Run the full verification commands.
bash
bun run typecheck bun run lint bun run test bun run test:coverage
- •If the template was intentionally stripped of test scaffolding, reintroduce:
- •
vitest,@effect/vitest,@vitest/coverage-v8dev dependencies - •
test,test:watch,test:coveragescripts - •
vitest.config.ts - •at least one
src/**/*.test.tsfile
Troubleshooting
- •Missing coverage provider:
- •Verify
@vitest/coverage-v8is installed.
- •Verify
- •ESM/CJS import errors:
- •Confirm
package.jsontypeandtsconfigmodule settings are compatible with Vitest.
- •Confirm
- •Coverage below threshold:
- •Add tests for missing branches before lowering thresholds.
- •Effect tests not recognized:
- •Confirm imports come from
@effect/vitest, not plainvitest, for Effect test files.
- •Confirm imports come from
Hand-Off To Other Skills
- •After setup succeeds, use
write-testsfor feature and bug-test implementation. - •If tracing/log correlation is also requested, use
setup-otel.