Skip to content

Checks and tests

Checks and tests

bolt check compiles the workspace and checks its types, its schema history and its declarations. bolt test runs your tests against a temporary database. Both run on any machine; no host is needed.

Tests

Tests live in tests/ and use Vitest with @effect/vitest. TestWorkspace.layer starts the workspace on a temporary database filled from seed/test/. t.as(holder) acts as an administrator, a member or an automation, so a test proves real permissions, not only code.

// tests/claims-and-costings.test.ts (a sketch)
import { expect, it } from '@effect/vitest';
import { Effect } from 'effect';
import { TestWorkspace } from '@norbital-ai/bolt-cli/test';

// PROJECT is the id of a project whose zones include 'L01'
it.effect('refuses a BOQ cost item for an undeclared project zone', () =>
	Effect.gen(function* () {
		const t = yield* TestWorkspace;
		const admin = yield* t.as(t.admin);
		const item = (zone: string) => ({
			item_code: 'BOQ-01',
			description: 'Suspended Slabs',
			project_id: PROJECT,
			zone,
			currency: 'SGD',
			contract_qty: '1',
			unit_rate: '100.00'
		});

		const refused = yield* Effect.flip(admin.act({ 'cost_items.create': [item('NO-SUCH-ZONE')] }));
		expect(refused).toMatchObject({ _tag: 'ActRefused' });

		const created = yield* admin.act({ 'cost_items.create': [item('L01')] });
		expect(created.kind).toBe('committed');
	}).pipe(Effect.provide(TestWorkspace.layer({ root: process.cwd(), now: '2026-06-01T00:00:00Z' })))
);

Test your own rules with small, made-up rows: one write that succeeds and one that is refused, then check what was saved. it.effect runs on a test clock; move it forward explicitly instead of waiting.

What happens when it runs

  1. bolt test starts the workspace on a temporary database filled from seed/test/.
  2. The first write creates a BOQ cost item for an undeclared project zone: it fails with ActRefused.
  3. The second write uses the declared zone L01 and comes back committed. Nothing touches a real database.