Initialize Bun Test
Set up bun test for this project.
Steps
- •
Detect if Effect project:
- •Check package.json for
effectdependency
- •Check package.json for
- •
Create
bunfig.toml:Standard project:
toml[test] root = "./src" testMatch = ["**/*.test.ts"]
Effect project:
toml[test] root = "./src" testMatch = ["**/*.test.ts"]
- •
Install test dependencies:
Standard project:
bashbun add -D @types/bun
Effect project:
bashbun add -D @types/bun @codeforbreakfast/bun-test-effect
- •
Add scripts to package.json:
json"test": "bun test", "test:watch": "bun test --watch"
- •
Create example test file (if no tests exist):
Standard (
src/example.test.ts):typescriptimport { describe, expect, it } from 'bun:test' describe('example', () => { it('works', () => { expect(1 + 1).toBe(2) }) })Effect (
src/example.test.ts):typescriptimport { describe, expect, it } from '@codeforbreakfast/bun-test-effect' import { Effect } from 'effect' describe('example', () => { it('works', () => { expect(1 + 1).toBe(2) }) it.effect('works with Effect', () => Effect.gen(function* () { const result = yield* Effect.succeed(42) expect(result).toBe(42) }) ) }) - •
Run tests to verify setup:
bashbun test
Ask before creating example test file if tests already exist.