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:1
Set Database Environment Variables
Use the Or set manually:
.test_database_urls/ helper scripts: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 allowin repository root
2
Clone Prisma Repository
Driver adapters are built from the main Prisma repo:
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: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