What Tests Are Implemented in usekaneo/kaneo? Unit, Integration, and E2E Coverage Explained
Kaneo uses Vitest to run two test types: fast unit tests in tests/api/ and full-stack integration tests in tests/api-integration/, with no dedicated E2E UI tests currently in the codebase.
The open-source project management platform Kaneo maintains a comprehensive test suite built on Vitest, a Vite-native test runner. According to the usekaneo/kaneo source code, the repository organizes tests into distinct categories that balance developer velocity with production reliability.
Unit Tests: Fast, Isolated Verification
Unit tests in Kaneo target individual functions and modules without external dependencies. These tests run in-memory, complete in milliseconds, and provide rapid feedback during development.
Location and Structure
Unit tests live in tests/api/**/*.test.ts. Key examples include:
tests/api/utils/verify-turnstile.test.ts— Turnstile validator logictests/api/database/*.test.ts— Drizzle helper functionstests/api/ws/*.test.ts— WebSocket adapter codetests/api/storage/*.test.ts— S3, Redis, and email wrapperstests/api/plugins/**/*.test.ts— GitHub and webhook plugin logic
Unit Test Configuration
The base configuration resides in apps/api/vitest.config.ts:
import { defineConfig } from 'vitest/config';
export default defineConfig({
test: {
globals: true,
environment: 'node',
include: ['tests/api/**/*.test.ts'],
},
});
This config enables Jest-compatible globals (describe, it, expect) and targets files under tests/api/.
Example Unit Test
// tests/api/utils/slugify.test.ts
import { describe, it, expect } from "vitest";
import { slugify } from "@/api/utils/slugify";
describe("slugify()", () => {
it("converts a title to a URL-safe slug", () => {
expect(slugify("Hello World!")).toBe("hello-world");
});
it("removes leading/trailing hyphens", () => {
expect(slugify("--My Project--")).toBe("my-project");
});
});
Integration Tests: Full-Stack API Verification
Integration tests exercise complete request-response cycles through the real Hono API server with an actual PostgreSQL database. These tests verify auth flows, database migrations, RBAC policies, and external service interactions.
Location and Scope
Integration tests occupy tests/api-integration/**/*.test.ts. Notable examples:
tests/api-integration/workspace-rbac.test.ts— Role-based access controltests/api-integration/project.test.ts— Project CRUD endpoints- Tests covering auth, device flows, and external service integration
Integration Test Architecture
The configuration in apps/api/vitest.integration.config.ts extends the base setup with global lifecycle hooks:
import { defineConfig } from 'vitest/config';
export default defineConfig({
test: {
globals: true,
globalSetup: './tests/api-integration/helpers/setup.ts',
include: ['tests/api-integration/**/*.test.ts'],
},
});
The global setup performs three critical operations:
- Launches the Hono API server on a test port
- Provisions a temporary PostgreSQL instance and applies migrations
- Injects test-specific environment variables including
DATABASE_URL
Example Integration Test
// tests/api-integration/project.test.ts
import { describe, it, expect, beforeAll, afterAll } from "vitest";
import request from "supertest";
import { startServer, stopServer } from "./helpers/setup";
let api: ReturnType<typeof request>;
beforeAll(async () => {
await startServer();
api = request(process.env.KANEO_API_URL);
});
afterAll(async () => {
await stopServer();
});
describe("Project endpoints", () => {
it("creates a project and returns its slug", async () => {
const res = await api
.post("/api/project")
.send({ name: "Demo Project" })
.set("Authorization", `Bearer ${process.env.TEST_TOKEN}`);
expect(res.status).toBe(201);
expect(res.body).toHaveProperty("slug", "demo-project");
});
});
End-to-End (E2E) Tests: Current Status
Kaneo does not implement dedicated E2E UI tests. There are no Cypress, Playwright, or Selenium suites in the repository. The integration tests serve as the highest level of automated verification, covering API behavior without browser automation.
This design choice reflects the project's current priorities: the React frontend relies on type-safe API contracts and manual testing, while the backend guarantees correctness through the integration test layer.
Running the Test Suites
Execute tests via pnpm scripts defined in root package.json:
# Install dependencies
pnpm install
# Run unit tests (fast, no database required)
pnpm test
# Run integration tests (requires Docker/PostgreSQL)
pnpm test:integration
The test alias maps to vitest run using the default config. The test:integration script invokes the integration-specific configuration.
Test Coverage Matrix
| Component | Unit Tests | Integration Tests |
|---|---|---|
| Valibot validators and schemas | ✅ tests/api/utils/ |
— |
| Drizzle database utilities | ✅ tests/api/database/ |
✅ tests/api-integration/ |
| WebSocket adapters | ✅ tests/api/ws/ |
— |
| S3/Redis/email wrappers | ✅ tests/api/storage/ |
✅ tests/api-integration/ |
| API routes and controllers | — | ✅ Full request cycles |
| Authentication and RBAC | — | ✅ Device auth, workspace permissions |
| GitHub/webhook plugins | ✅ tests/api/plugins/ |
— |
Summary
- Unit tests in
tests/api/provide rapid, isolated verification of utilities, validators, and plugins viaapps/api/vitest.config.ts - Integration tests in
tests/api-integration/spin up the full API stack with PostgreSQL throughapps/api/vitest.integration.config.ts - E2E tests are not currently implemented; integration tests cover the highest verification layer
- Run
pnpm testfor unit tests andpnpm test:integrationfor full-stack coverage
Frequently Asked Questions
Does Kaneo use Jest or Vitest for testing?
Kaneo uses Vitest. The configuration files apps/api/vitest.config.ts and apps/api/vitest.integration.config.ts define the test environments. Vitest provides Jest-compatible globals (describe, it, expect) for familiar syntax while offering native Vite integration and faster execution.
How do Kaneo's integration tests handle database state?
Integration tests use a global setup module referenced in apps/api/vitest.integration.config.ts. This module provisions a temporary PostgreSQL instance, applies Drizzle migrations, and injects a test-specific DATABASE_URL before any tests execute. The database is torn down after the suite completes, ensuring clean isolation between runs.
Why doesn't Kaneo have Playwright or Cypress E2E tests?
The project currently relies on integration tests as the highest automated verification layer. The React frontend is validated through type-safe API contracts and manual testing. According to the repository structure, no browser automation tooling is configured, though this could be added as the project matures.
Can I run integration tests without Docker?
No. The integration test suite requires Docker to provision the PostgreSQL container used during test execution. The global setup in tests/api-integration/helpers/setup.ts orchestrates this container lifecycle. Unit tests have no external dependencies and run entirely in-memory.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →