Testing Strategy

Five-Layer Test Approach

MapGPU uses a comprehensive test strategy with five distinct layers:

1. Unit Tests (CI, no GPU)

  • Framework: Vitest for TypeScript, cargo test for Rust
  • Scope: Pure logic — projections, math, state machines, parsers
  • Co-located: Tests live next to source files (*.test.ts)
  • Count: ~1,500+ tests across 11 packages
pnpm run test:unit

2. WASM Binding Tests (CI, no GPU)

  • Framework: wasm-pack test
  • Scope: Verify Rust ↔ JS boundary works correctly
  • Tests: TypedArray round-trips, error propagation, memory ownership
cd packages/wasm-core
wasm-pack test --node

3. WebGPU Logic Tests (CI, mock GPU)

  • Framework: Vitest with mock GPUDevice
  • Scope: Pipeline creation logic, buffer management, bind group layout
  • No real GPU required — tests validate orchestration, not rendering

4. Visual/Render Tests (self-hosted GPU runner)

  • Framework: Playwright + Chrome
  • Scope: Pixel-level rendering verification
  • Process: Render → screenshot → compare against baseline
  • Runner: Requires a machine with GPU access

5. Benchmark Tests (self-hosted GPU runner)

  • Framework: Playwright + Criterion (Rust)
  • Scope: Performance regression detection
  • Metrics: Frame time, pipeline creation time, WASM computation throughput

Test Coverage by Package

PackageTestsFocus
core-ts558MapView, ViewCore, modes, projections, renderers
render-webgpu261Pipelines, delegates, GLTF parser
layers213All layer types
widgets19211 widget classes
tools136Drawing, measurement, snap engine
adapters-ogc106WMS, WFS, OGC API
wasm-core67Rust unit tests
analysis54LOS, viewshed, buffer
react50React wrapper components
testing21Test utilities

Running Tests

# All tests
pnpm run test

# Unit tests only (fast, no build required)
pnpm run test:unit

# Single package
pnpm --filter @mapgpu/core run test

# Rust tests
cd packages/wasm-core && cargo test