Skip to main content

Test Organization

Prisma Engines has two main test categories:
  1. Unit tests - Test internal functionality of individual crates and components
  2. Integration tests - Run end-to-end requests through the driver adapter executor and schema engine

Unit Tests

Unit tests are distributed across the codebase, typically in ./tests folders at the root of modules.

Run All Unit Tests

To run unit tests for the whole workspace (excluding integration suites):
This excludes crates that require external services:
  • quaint
  • query-engine-tests
  • sql-migration-tests
  • schema-engine-cli
  • sql-schema-describer
  • sql-introspection-tests
  • mongodb-schema-connector

Run Tests for Specific Crates

Update Test Snapshots

Many tests use expect! macro snapshots. When diagnostics or output changes:
Always review snapshot diffs to ensure changes are intentional before committing.

Integration Tests

Schema Engine Tests

Schema engine tests require database connections. Set environment variables or use helper scripts:
1

Set Database Environment Variables

Use the .test_database_urls/ helper scripts:
Or set manually:
2

Run Schema Engine Tests

Connector Test Kit (Query Compiler)

The connector test kit exercises the query compiler and driver adapters end-to-end.

Architecture

The test kit consists of three crates:
  • query-engine-tests: Actual integration tests in tests/ folder
  • query-test-macros: Macro definitions (#[connector_test], #[test_suite])
  • query-tests-setup: Test configuration, connector tags, runners, logging

Prerequisites

1

Install Dependencies

  • Rust toolchain
  • Docker (for SQL connectors)
  • Node.js ≥ 20 and pnpm (for driver adapters)
  • direnv allow in repository root
2

Clone Prisma Repository

Driver adapters are built from the main Prisma repo:

Setup Test Environment

Use dev-*-qc Makefile helpers to set up databases and build artifacts:
These targets:
  1. Start the database container (if needed)
  2. Build query compiler Wasm (build-qc-wasm-fast)
  3. Build driver adapters kit (build-driver-adapters-kit-qc)
  4. Write .test_config file

Configuration

Tests use either environment variables or a .test_config file: Environment Variables:
Config File (Recommended):
.test_config
The config file should be in the current working directory or $WORKSPACE_ROOT.

Run Connector Tests

Run with Make Targets

Test Specific Driver Adapters

Set DRIVER_ADAPTER environment variable:
Or use dedicated targets:

Driver Adapter Configuration

For advanced driver adapter testing, set these environment variables:

Relation Loading Strategies

Test different relation loading strategies:

Database Management

Start All Databases

Stop All Databases

Start Specific Databases

Snapshot Testing with Insta

Many tests use insta for snapshot assertions.

Install cargo-insta

Run Tests with Insta

Don’t blindly accept all snapshots! Always review changes carefully to ensure they match expected behavior.

Test Environment Variables

Key environment variables for testing:

Benchmarking

Run Query Compiler Benchmarks

Save Benchmark Baseline

Compare Against Baseline

Profile Query Compiler

Troubleshooting

Tests Skip with “Missing TEST_DATABASE_URL”

Set the required environment variables or use the helper scripts:

expect! Snapshot Failures

Update snapshots when output changes:

Driver Adapter Build Fails

Ensure ../prisma repository is checked out:

Tests Run Concurrently Causing Issues

Use single-threaded execution:

Next Steps