Skip to main content

Deterministic visual regression testing CLI for Django platforms.

Project description

django-vrt

django-vrt (djvrt) is a Python-first visual regression testing package for Django platforms.

It is built for large, fast-moving UI systems where you need deterministic screenshots, repeatable CI, and safe baseline promotion.

Core value

  • Deterministic lockfile matrix (djvrt.lock.json)
  • Reproducible baseline and check workflows
  • Built-in screenshot diffing and CI reports
  • Interactive HTML review UI with filter/sort and image comparison modes
  • Django route discovery from sitemap and URLConf
  • Data and model seeding hooks for stable UI state
  • Package-first extension model for complex projects

Install

Consumer project:

uv add django-vrt
uv run playwright install chromium

Package development:

uv sync --extra dev
uv run playwright install chromium

Quickstart

uv run djvrt init
uv run djvrt discover --settings your_project.settings
uv run djvrt lock
uv run djvrt baseline
uv run djvrt check

Artifacts are stored in .djvrt/ by default.

Getting Started Checklist

  1. Install package + Chromium.
  2. Generate config/scenarios with djvrt init.
  3. Discover routes (or provide deterministic seeded scenarios).
  4. Build djvrt.lock.json with djvrt lock.
  5. Capture baseline once with djvrt baseline.
  6. Gate PRs using djvrt check.

CLI commands

  • djvrt init: create djvrt.toml and starter scenarios
  • djvrt discover: discover URL scenarios
  • djvrt lock: compile deterministic matrix lockfile
  • djvrt baseline: capture baseline images
  • djvrt check: compare current screenshots against baseline
  • djvrt report: regenerate HTML and JUnit reports from summary.json
  • djvrt approve: promote run actual/ images to baseline
  • djvrt auth-state: capture Playwright storage_state JSON
  • python -m djvrt.django_seed_cli: run hook-driven project seeding

Tip: add --open to djvrt baseline, djvrt check, or djvrt report to auto-open the generated HTML report.

Package-first integration model

Use django-vrt as the shared engine. Keep consumer-repo code limited to small extension modules:

  • seeder class (module:Class) implementing BaseDjangoVRTSeeder
  • optional setup hook (module:function) to call django.setup()
  • optional options builder (module:function) for project-specific seed options

This keeps custom logic minimal and avoids per-project forks of VRT infrastructure.

Determinism checklist

  • Commit uv.lock
  • Commit djvrt.lock.json for the baseline contract
  • Pin Python version and Playwright version
  • Install Chromium in CI (playwright install chromium)
  • Run on a stable OS image with controlled fonts
  • Prefer deterministic data hooks (get_or_create, fixed identifiers)
  • Set runtime.js_random_seed in djvrt.toml when frontend code uses Math.random()
  • Set runtime.always_write_diff_images = true if you need diff overlays for passed scenarios

Deployment to PyPI

django-vrt is automatically published to PyPI via GitHub Actions. There are three ways to trigger a release:

1. GitHub Release (Recommended)

Create a new release through the GitHub UI:

  1. Go to Releases → "Create a new release"
  2. Set tag (e.g., v0.2.0) and title
  3. Click "Publish release"
  4. The workflow automatically builds and publishes to PyPI

2. Version Tag Push

Push a version tag directly:

git tag v0.2.0
git push origin v0.2.0

This triggers the build and publish automatically.

3. Manual Workflow Trigger

Run the publish workflow manually from GitHub:

  1. Go to Actions → "publish" workflow
  2. Click "Run workflow" → "Run workflow"
  3. The current main branch code is built and published

Pre-release checklist

Before releasing:

  • Update version in pyproject.toml (version = "x.y.z")
  • Update CHANGELOG.md or release notes (if applicable)
  • Ensure all tests pass: uv sync --extra dev && uv run pytest
  • Verify linting: uv run ruff check .
  • Commit and push changes to main

How it works

The publish workflow (.github/workflows/publish.yml) does the following:

  1. Build stage: Installs dependencies, builds wheel and source distributions, validates metadata
  2. Publish stage: Downloads artifacts and publishes to PyPI using OIDC authentication (no API key needed)

The workflow uses GitHub's trusted publisher model for PyPI authentication. No secrets need to be configured—PyPI automatically trusts builds from this repository.

Documentation map

  • /docs/quickstart.md
  • /docs/configuration.md
  • /docs/django-seeding.md
  • /docs/ci.md
  • /docs/local-playbook.md

Examples

  • CI workflow: examples/github-actions.yml
  • Seeder adapter template: examples/django_seed_adapter.py

Sponsors

This project is developed with support from Mabyduck — Evaluating AI-generated audio, images, and videos with human feedback.

Special thanks to Lucas Theis (LinkedIn) for enabling this work during business hours. Project maintained by William Blackie (LinkedIn).

Learn more: Mabyduck on GitHub | Mabyduck on LinkedIn

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django_vrt-0.0.1.tar.gz (136.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_vrt-0.0.1-py3-none-any.whl (41.9 kB view details)

Uploaded Python 3

File details

Details for the file django_vrt-0.0.1.tar.gz.

File metadata

  • Download URL: django_vrt-0.0.1.tar.gz
  • Upload date:
  • Size: 136.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for django_vrt-0.0.1.tar.gz
Algorithm Hash digest
SHA256 b1fa42b154dc7a1dade6f512adfe68b46cebe3c973991cf5d982b26b19f76e70
MD5 3f2e6eeedcc04ea0189c5b303484edc7
BLAKE2b-256 9d67618c096efaed3c9e007cee3f1520236a536e0943ae31ade286c877ab2a80

See more details on using hashes here.

Provenance

The following attestation bundles were made for django_vrt-0.0.1.tar.gz:

Publisher: publish.yml on William-Blackie/django-vrt

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file django_vrt-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: django_vrt-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 41.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for django_vrt-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 421a0ba71b076368703023d8619488aabf0d438e2736c4ebc11e9ec172eab159
MD5 1ea67e8a76c6572ce675e9e33ddf300f
BLAKE2b-256 a0f8f4a4f341e2cf840676c1e19588d4ea646abee572989359f90e7effa769c3

See more details on using hashes here.

Provenance

The following attestation bundles were made for django_vrt-0.0.1-py3-none-any.whl:

Publisher: publish.yml on William-Blackie/django-vrt

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page