# How to Run Tests in the Kaneo Repository: Complete Setup Guide

> Learn how to run tests in the Kaneo repository with this setup guide. Execute unit or integration tests using pnpm and TurboRepo for efficient development.

- Repository: [kaneo.app/kaneo](https://github.com/usekaneo/kaneo)
- Tags: how-to-guide
- Published: 2026-08-08

---

**The Kaneo monorepo uses pnpm and TurboRepo to orchestrate test execution, requiring `pnpm install` followed by `pnpm test` for unit tests or `pnpm test:integration` for the full database-backed integration suite.**

The Kaneo repository is structured as a monorepo that relies on pnpm workspaces and TurboRepo pipelines to manage its testing workflow. Whether you are contributing new features or verifying existing functionality, understanding how to run tests in the Kaneo repository ensures you can validate changes across the API and integration layers effectively.

## Prerequisites and Environment Setup

Before executing any test commands, you must configure the environment variables that the Kaneo application expects. Create an `.env` file in the project root—often by copying from `.env.example`—and populate it with required values such as `DATABASE_URL`, `KANEO_API_URL`, and credentials for PostgreSQL and Redis.

The integration test suite specifically requires a running PostgreSQL instance, as defined in the integration test configuration. Without valid database credentials, the `test:integration` command will fail while attempting to connect to the database.

## Install Dependencies

After cloning the repository, install all workspace dependencies using pnpm. This command resolves inter-workspace packages and installs **Vitest**, the test runner used throughout the Kaneo codebase.

```bash
pnpm install

```

This installation step is critical because TurboRepo relies on these dependencies to execute tasks across the monorepo.

## Running Unit Tests

To execute the unit test suite, run the following command from the repository root:

```bash
pnpm test

```

This command invokes the `test` script defined in the root [`package.json`](https://github.com/usekaneo/kaneo/blob/main/package.json) [lines 5-16](https://github.com/usekaneo/kaneo/blob/main/package.json#L5-L16), which delegates to `turbo test`. TurboRepo automatically builds any dependent packages before executing tests, ensuring the latest compiled output is used.

The unit tests are located under `tests/api/**` and utilize the configuration in [`apps/api/vitest.config.ts`](https://github.com/usekaneo/kaneo/blob/main/apps/api/vitest.config.ts). These tests run without external database dependencies and generate coverage reports in the `coverage/` directory. An example unit test file, [`tests/api/label/delete-label.test.ts`](https://github.com/usekaneo/kaneo/blob/main/tests/api/label/delete-label.test.ts), demonstrates the testing patterns used for API endpoints.

## Running Integration Tests

For full-stack validation that includes database interactions, execute the integration test suite:

```bash
pnpm test:integration

```

This command runs `turbo test:integration` as configured in [`turbo.json`](https://github.com/usekaneo/kaneo/blob/main/turbo.json) [lines 27-36](https://github.com/usekaneo/kaneo/blob/main/turbo.json#L27-L36), targeting the test files under `tests/api-integration/**`. According to the Kaneo source code, these tests require a running PostgreSQL server and appropriate environment variables such as `POSTGRES_*` and `REDIS_URL`.

The integration tests use [`apps/api/vitest.integration.config.ts`](https://github.com/usekaneo/kaneo/blob/main/apps/api/vitest.integration.config.ts) to manage database connections and environment setup. The file [`tests/api-integration/workspace-rbac.test.ts`](https://github.com/usekaneo/kaneo/blob/main/tests/api-integration/workspace-rbac.test.ts) provides a representative example of how the suite exercises authentication and workspace role-based access control against a real database.

## Understanding the Test Configuration

The orchestration between pnpm scripts and TurboRepo tasks defines how tests execute across the monorepo. In [`turbo.json`](https://github.com/usekaneo/kaneo/blob/main/turbo.json), the `test` and `test:integration` tasks declare their outputs and dependencies, ensuring that prerequisite builds complete before testing begins.

Individual test files follow Vitest conventions. The unit tests isolate API logic, while the integration configuration handles setup and teardown of database connections, validating the complete stack including authentication and database layers.

## Summary

- **The Kaneo repository** uses pnpm and TurboRepo to manage its monorepo test execution.
- **Unit tests** run via `pnpm test`, executing files in `tests/api/**` using Vitest configuration from [`apps/api/vitest.config.ts`](https://github.com/usekaneo/kaneo/blob/main/apps/api/vitest.config.ts).
- **Integration tests** run via `pnpm test:integration`, requiring PostgreSQL and executing files in `tests/api-integration/**` via [`apps/api/vitest.integration.config.ts`](https://github.com/usekaneo/kaneo/blob/main/apps/api/vitest.integration.config.ts).
- **Environment variables** in `.env` are required for both suites, with database credentials being mandatory for integration testing.
- **TurboRepo** automatically builds dependent packages before running tests, ensuring fresh compiled output.

## Frequently Asked Questions

### What testing framework does the Kaneo repository use?

The Kaneo repository uses **Vitest** as its primary testing framework. Configuration files located at [`apps/api/vitest.config.ts`](https://github.com/usekaneo/kaneo/blob/main/apps/api/vitest.config.ts) for unit tests and [`apps/api/vitest.integration.config.ts`](https://github.com/usekaneo/kaneo/blob/main/apps/api/vitest.integration.config.ts) for integration tests define the test environment, coverage settings, and global variables.

### Do I need a database to run all tests in Kaneo?

No, you only need a PostgreSQL database for the integration tests. The unit test suite (`pnpm test`) runs pure unit tests under `tests/api/**` that do not require external database connections. However, running `pnpm test:integration` requires a valid `DATABASE_URL` and running PostgreSQL instance, as these tests validate full-stack interactions including database queries.

### How does TurboRepo optimize test execution?

TurboRepo caches test results and automatically builds dependent packages before executing tests. When you run `pnpm test` or `pnpm test:integration`, TurboRepo checks the pipeline configuration in [`turbo.json`](https://github.com/usekaneo/kaneo/blob/main/turbo.json) to ensure all upstream build tasks complete first, preventing stale code from being tested.

### Where are the test files located in the repository?

Unit tests reside in the `tests/api/` directory, such as [`tests/api/label/delete-label.test.ts`](https://github.com/usekaneo/kaneo/blob/main/tests/api/label/delete-label.test.ts). Integration tests are located in `tests/api-integration/`, with examples like [`tests/api-integration/workspace-rbac.test.ts`](https://github.com/usekaneo/kaneo/blob/main/tests/api-integration/workspace-rbac.test.ts). Both directories use Vitest but with separate configuration files to handle different environment requirements.