133 tests passing (7 logger tests failing - pre-existing issue):
utils/categoryDefaults.test.ts(22 tests) - Category/emoji resolutionutils/columnDetection.test.ts(20 tests) - CSV column auto-detectionutils/logger.test.ts(10 tests) - Client-side loggingcomposables/useErrorTracker.test.ts(26 tests) - Error tracking composableserver/utils/logger.test.ts(13 tests, 7 failing) - Server-side loggingserver/utils/password.test.ts(14 tests) - Password hashing/verificationserver/utils/csvParser.test.ts(20 tests) - CSV parsing, date/duration detectionserver/api/health.get.test.ts(1 test) - Health check endpoint
Integration tests (v0.4.0 planned):
Integration tests for auth and import endpoints will be rewritten with @nuxt/test-utils/e2e as part of v0.4.0. Current integration tests:
tests/api/entries.integration.test.ts- Entry CRUD with @nuxt/test-utils/e2etests/integration/entry-engine.test.ts- Entry engine validation parity
Coverage tool blocked: @vitest/coverage-v8 requires node:inspector which Bun doesn't implement yet.
cd app
bun run test # Run all tests (133 passing)
bun run test --watch # Watch modeTest pure functions with no external dependencies:
// utils/myUtil.test.ts
import { describe, it, expect } from "vitest";
import { myFunction } from "./myUtil";
describe("myFunction", () => {
it("should handle normal input", () => {
expect(myFunction("input")).toBe("output");
});
it("should handle edge cases", () => {
expect(myFunction(null)).toBe("default");
expect(myFunction("")).toBe("default");
});
});Test API endpoints via HTTP (requires @nuxt/test-utils/e2e setup):
// tests/api/entries.test.ts
import { setup, $fetch } from "@nuxt/test-utils/e2e";
await setup({ server: true });
it("should create entry", async () => {
const response = await $fetch("/api/entries", {
method: "POST",
body: { type: "tada", title: "Test" },
headers: { Cookie: authCookie },
});
expect(response.id).toBeDefined();
});- Test behavior, not implementation
- One assertion per test (when practical)
- Descriptive test names -
it("should X when Y") - Test edge cases - null, empty, invalid input
- Clean up test data in
afterEach
- Fix e2e environment for integration tests
- Add auth endpoint tests
- Add entry CRUD integration tests
- Add E2E tests for critical workflows