@reionjs/vitest
v0.0.1
Published
Vitest helpers for Reion: auto boot from reion.config, HTTP request client
Readme
@reionjs/vitest
Vitest helpers for Reion: boot a real HTTP server from reion.config.*, inject a small request client into tests, and tear down automatically.
Install
bun add -d vitest @reionjs/vitestPeer dependencies: reion, vitest.
Setup with CLI
Use Reion CLI for automatic setup:
reion add -p @reionjs/vitestThis setup does:
- installs
@reionjs/vitest(handled byreion add) - installs
vitest(unless you use--skip-install) - creates
vitest.config.tsif it does not exist - sets
package.jsonscript:"test": "vitest run"
When creating vitest.config.ts, setup prompts whether to add alias config:
- optional
@alias (@->./src) for projects using tsconfig paths
If vitest.config.ts already exists, setup leaves it unchanged.
Usage
import { describe, it, expect } from "@reionjs/vitest";
describe("API", () => {
it("GET /api/hello", async ({ request }) => {
const res = await request.get("/api/hello");
expect(res.status).toBe(200);
});
});- Use
describe/itfrom this package (not plainvitest) so the suite gets a Reion server fromprocess.cwd()+reion.config.*. - For custom setups, use
createTestServer()andcreateRequestClient()directly.
See the docs: Plugins → Vitest helpers.
Development
bun run build
bun run test