Test Organization
Prisma Engines has two main test categories:- Unit tests - Test internal functionality of individual crates and components
- 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):quaintquery-engine-testssql-migration-testsschema-engine-clisql-schema-describersql-introspection-testsmongodb-schema-connector
Run Tests for Specific Crates
Update Test Snapshots
Many tests useexpect! macro snapshots. When diagnostics or output changes:
Integration Tests
Schema Engine Tests
Schema engine tests require database connections. Set environment variables or use helper scripts: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
Install Dependencies
- Rust toolchain
- Docker (for SQL connectors)
- Node.js ≥ 20 and pnpm (for driver adapters)
direnv allowin repository root
Setup Test Environment
Usedev-*-qc Makefile helpers to set up databases and build artifacts:
- Start the database container (if needed)
- Build query compiler Wasm (
build-qc-wasm-fast) - Build driver adapters kit (
build-driver-adapters-kit-qc) - Write
.test_configfile
Configuration
Tests use either environment variables or a.test_config file:
Environment Variables:
.test_config
$WORKSPACE_ROOT.
Run Connector Tests
Run with Make Targets
Test Specific Driver Adapters
SetDRIVER_ADAPTER environment variable:
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 useinsta for snapshot assertions.
Install cargo-insta
Run Tests with Insta
Test Environment Variables
Key environment variables for testing:| Variable | Description |
|---|---|
WORKSPACE_ROOT | Path to repository root |
TEST_CONNECTOR | Connector to test (postgres, mysql, etc.) |
TEST_CONNECTOR_VERSION | Connector version (13, 8, etc.) |
DRIVER_ADAPTER | Driver adapter name (pg, neon, planetscale) |
DRIVER_ADAPTER_CONFIG | JSON config for driver adapter |
EXTERNAL_TEST_EXECUTOR | Path to test executor script |
TEST_DATABASE_URL | Primary database connection string |
TEST_SHADOW_DATABASE_URL | Shadow database for migrations |
LOG_LEVEL | Logging level (trace, debug, info) |
RUST_LOG | Rust logging filter |
UPDATE_EXPECT | Set to 1 to update expect! snapshots |
SIMPLE_TEST_MODE | Reduces relation_link_test tests |
RELATION_TEST_IDX | Run specific relation test by index |
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
- Learn about debugging techniques
- Review contribution guidelines
- Explore the connector test kit README