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

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.

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:

pnpm test

This command invokes the test script defined in the root package.json lines 5-16, 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. 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, demonstrates the testing patterns used for API endpoints.

Running Integration Tests

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

pnpm test:integration

This command runs turbo test:integration as configured in turbo.json lines 27-36, 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 to manage database connections and environment setup. The file 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, 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.
  • Integration tests run via pnpm test:integration, requiring PostgreSQL and executing files in tests/api-integration/** via 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 for unit tests and 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 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. Integration tests are located in tests/api-integration/, with examples like tests/api-integration/workspace-rbac.test.ts. Both directories use Vitest but with separate configuration files to handle different environment requirements.

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:

Share the following with your agent to get started:
curl -s "https://instagit.com/install.md"

Works with
Claude Codex Cursor VS Code OpenClaw Any MCP Client

Maintain an open-source project? Get it listed too →