Skip to content

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.

Terminal window
aerostack test [flags]
FlagDescription
--coverageGenerate a coverage report
Terminal window
# Run all tests
aerostack test
# Run with coverage
aerostack test --coverage
  1. Auto-generates .aerostack/wrangler.test.toml with test bindings
  2. Builds dist/worker.js
  3. Runs Vitest with @cloudflare/vitest-pool-workers

Tests have access to all D1, KV, and other bindings, running in the actual Workers runtime.

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: 'test@example.com', password: 'securepass' })
})
expect(response.status).toBe(201)
const body = await response.json()
expect(body.user.email).toBe('test@example.com')
})
})

Tests read your aerostack.toml for bindings. The test environment uses local D1 and KV, isolated per test run.