Skip to content

Testing ​

MVT's strict separation makes testing straightforward. Models are deterministic - call update(), assert state. Views produce pixels - capture and compare. Neither depends on the other.

Related: Models (Learn) - Views (Learn) - Model Composition


Philosophy ​

Test against public, specified behaviours - not internal implementation details. A model test calls public methods and asserts on public properties. A view test captures visual output and compares against a known baseline. If either layer's internals change, tests should not break unless the observable result changes.

This project uses Vitest for model and view model tests, and Playwright for visual snapshot tests.

Testing by Layer ​

LayerWhat to testHowPage
ModelsState, transitions, compositionupdate() + assert valuesTesting Models
View modelsPresentation state transformsupdate() + assert valuesTesting Models
ViewsVisual correctnessVisual snapshotsTesting Views

Models and view models are tested the same way - they are both stateful objects with a public API and no rendering dependency. Views are a fundamentally different problem because their output is pixels, not values.