aerostack test
Run your project’s tests using Vitest with the Cloudflare Workers runtime pool. Tests run in an environment that matches your production edge runtime.
Usage
aerostack test [flags]Flags
| Flag | Description |
|---|---|
--coverage | Generate a coverage report |
Examples
# Run all tests
aerostack test
# Run with coverage
aerostack test --coverageHow it works
- Auto-generates
.aerostack/wrangler.test.tomlwith test bindings - Builds
dist/worker.js - Runs Vitest with
@cloudflare/vitest-pool-workers
Tests have access to all D1, KV, and other bindings, running in the actual Workers runtime.
Writing tests
// src/__tests__/auth.test.ts
import { describe, it, expect } from 'vitest'
import { env } from 'cloudflare:test'
describe('auth', () => {
it('registers a new user', async () => {
const response = await fetch('http://localhost/v1/public/projects/my-app/auth/register', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ email: '[email protected]', password: 'securepass' })
})
expect(response.status).toBe(201)
const body = await response.json()
expect(body.user.email).toBe('[email protected]')
})
})Configuration
Tests read your aerostack.toml for bindings. The test environment uses local D1 and KV, isolated per test run.
Add aerostack test to your CI pipeline to catch regressions before deploying.