Skip to main content

Testing Standards

Asset360 v3 maintains comprehensive test coverage using Vitest.

Test Structure

Tests are organized in the test/ directory:

test/
├── service/ # Service layer tests
├── coordinator/ # Coordinator tests
├── domain/ # Domain logic tests
└── helpers/ # Shared test utilities

Writing Tests

import { describe, it, expect, beforeAll } from "vitest";
import { createDomainServices } from "@worker/services/factory";
import { getTestDB } from "../helpers/setup";

describe("FundService", () => {
let services: DomainServices;

beforeAll(async () => {
const db = await getTestDB();
services = createDomainServices({ db, env: {} as Env });
});

it("creates a fund", async () => {
const fund = await services.fund.createFund({
name: "Test Fund",
code: "TEST01",
organizationId: "org-1",
startDate: new Date(),
});

expect(fund.id).toBeDefined();
expect(fund.name).toBe("Test Fund");
});
});

Test Isolation

Each test should be independent. See Test Isolation for details.

Coverage Requirements

Maintain test coverage across all services and coordinators.

See Also