Introducing a new way to review your PRs.

Read the announcement

getredash / redash

Make Your Company Data Driven. Connect to any data source, easily visualize, dashboard and share your data.

View on GitHub

20 documents · Updated Nov 11, 2026

docs / visual-regression-testing

Visual regression testing

Visual regression testing checks that Redash visualizations still render as expected in a real browser. The harness creates a known set of queries and dashboards, captures each visualization as an image, and compares the result with a committed baseline so layout, styling, labels, and data presentation changes become visible during development and CI.

Test harness

The browser harness uses Playwright in a fixed desktop browser environment. A seed project prepares the Redash instance first, and the visualization project depends on that setup before it opens public dashboards and captures widget images (client/…/playwright.config.ts• L10-45). This keeps data creation and image comparison as two linked stages of one test run.

The preferred command runs inside the official Playwright Docker image. The image fixes the operating system, browser build, and fonts that affect pixels, while CI runs the same command against a containerized Redash server and worker (client/…/docker.sh• L1-28, .github/…/ci.yml• L183-227). Local browser runs help inspect examples, but their images are not expected to match the committed baselines.

The harness uses a fixed viewport and disables animation and the text caret during capture. It also keeps a trace on failed runs and writes an HTML report under client/visual-tests/.results for diagnosis (client/…/playwright.config.ts• L14-29).

References: client/…/playwright.config.ts• L4-45 client/…/docker.sh• L1-28 .github/…/ci.yml• L183-227

Seeded example data

The seed stage turns the examples into a temporary, repeatable Redash workspace. It connects with an API key when one is supplied. Otherwise it uses the configured account credentials and can initialize a fresh Redash instance before login (client/…/api.ts• L3-41).

The examples use the Chinook sample music-store database as their shared source. The seed stage registers that SQLite file, removes the current user's older tagged examples, creates and executes the example queries, and waits for the worker to finish. It then creates visualizations and one public dashboard for each visualization type (client/…/seed.setup.ts• L6-16, client/…/seed.setup.ts• L21-52, client/…/seed.setup.ts• L58-125).

The generated workspace is disposable. A tag and naming rule identify the harness-owned dashboards and queries without deleting unrelated content on a shared instance. The seed also requires custom JavaScript visualizations to be enabled because one example covers a custom chart (client/…/seed.setup.ts• L58-90).

References: client/…/api.ts• L3-41 client/…/seed.setup.ts• L6-16 client/…/seed.setup.ts• L21-52 client/…/seed.setup.ts• L58-125 .ci/compose.cypress.yaml• L7-16

Example scenarios

The scenario catalog combines SQL result shapes with visualization settings. Each query can support several named visualizations, so one data set can check both normal rendering and option variants such as axes, colors, labels, filters, formatting, links, map markers, and empty or uneven paths (client/…/examples.ts• L1-10, client/…/examples.ts• L129-194).

The catalog covers the main visualization families used by the product:

  • Charts and deprecated boxplots.
  • Tables, details views, counters, pivot tables, cohorts, and funnels.
  • Marker maps and choropleth maps.
  • Sankey diagrams, sunburst sequences, and word clouds.

Each visualization type has its own dashboard. The seed places matching widgets into that dashboard, using a standard size unless a scenario needs a custom size. This groups related variants side by side and gives the browser test a stable route from a visualization name to its widget (client/…/examples.ts• L12-71, client/…/seed.setup.ts• L128-167).

References: client/…/examples.ts• L1-71 client/…/examples.ts• L129-194 client/…/seed.setup.ts• L128-167

Dashboard manifest

The seed stage writes a manifest that connects each visualization type to its public dashboard path and widget IDs. The browser stage reads this file instead of guessing server-generated IDs, so it can open the right dashboard and locate each named widget after the data has been recreated (client/…/manifest.ts• L5-34).

The manifest is a handoff between the two Playwright projects:

  1. The seed creates dashboards and widgets.
  2. The seed shares each dashboard and records its public path.
  3. The seed writes the dashboard and widget map to .results/manifest.json.
  4. The visual test reads the map and captures the corresponding widgets.

If the manifest is missing, the run stops with an instruction to run the seed project. This prevents screenshots from running against an unprepared or unknown workspace (client/…/manifest.ts• L23-34).

This diagram shows how example definitions become public dashboards and then screenshot results.

flowchart LR
    Examples[Example queries and settings] --> Seed[Seed Redash workspace]
    Chinook[Chinook SQLite data] --> Seed
    Seed --> Queries[Executed queries and visualizations]
    Queries --> Dashboards[Public dashboards by type]
    Dashboards --> Manifest[Dashboard and widget manifest]
    Manifest --> Browser[Playwright browser run]
    Browser --> Images[Widget screenshots]
    Images --> Compare[Baseline comparison]

References: client/…/manifest.ts• L5-34 client/…/seed.setup.ts• L128-167 client/…/visualizations.spec.ts• L31-50

Screenshot scenarios

The browser stage visits each public dashboard and checks every widget that belongs to that visualization type. It scrolls each widget into view and records a separate image whose path is based on the dashboard and visualization names (client/…/visualizations.spec.ts• L31-52). A name collision after slug conversion is treated as a test setup error because it could make two scenarios share one baseline.

The capture process removes sources of accidental variation before comparison. Random layouts use a fixed pseudo-random sequence, and external map tile requests are replaced with one plain image. The screenshot stylesheet hides relative “updated” times whose text and width change between seed runs (client/…/visualizations.spec.ts• L5-29, client/…/screenshot.css• L1-6).

Each image is checked as a soft assertion within its dashboard test. This lets the run report several changed widgets in one pass instead of stopping at the first mismatch. The resulting report contains expected, actual, and diff images for failed comparisons (client/…/README.md• L46-50).

References: client/…/visualizations.spec.ts• L5-52 client/…/screenshot.css• L1-6 client/…/README.md• L46-50

Screenshot baselines

The baseline set is the committed image record of the accepted rendering for each scenario. Playwright stores images under client/visual-tests/__screenshots__, grouped by dashboard and named from the visualization title (client/…/playwright.config.ts• L10-14, client/…/README.md• L1-5).

The comparison has no pixel tolerance because the Docker image is intended to make rendering deterministic. A changed character can therefore fail a small widget, which makes the suite sensitive to changes in text, spacing, color, chart shape, and other visible output (client/…/playwright.config.ts• L22-29, client/…/README.md• L52-58).

Baseline updates are an explicit review action. When a rendering change is intended, run the Docker command with --update-snapshots, inspect the new images, and commit the changed baselines with the scenario or product change. Do not accept a baseline only because the image changed; first decide whether the new rendering is the expected product behavior (client/…/README.md• L25-33).

References: client/…/playwright.config.ts• L10-29 client/…/README.md• L1-5 client/…/README.md• L25-33 client/…/README.md• L52-58

Regression workflow

The normal workflow starts a Redash server with a worker, enables custom JavaScript visualizations, and makes the Chinook file readable to the worker. The visual test command then seeds the examples and compares the browser output with the committed images (client/…/README.md• L16-23).

Use the following sequence when checking a change:

  1. Start the Redash services and confirm that the configured base URL is reachable.
  2. Run pnpm visual-tests:docker to seed the workspace and compare screenshots.
  3. Open the Playwright report when a comparison fails.
  4. Separate an environment or seed failure from a real rendering difference.
  5. If the change is intended, rerun with --update-snapshots and review the resulting image diff.
  6. Keep the new baseline only when it represents the accepted rendering.

CI follows the same high-level path. It builds the server, worker, and scheduler, creates the test database, waits for the server health check, runs the Docker-based visual suite, and stores .results as an artifact when the run fails (.github/…/ci.yml• L208-227).

References: client/…/README.md• L16-50 .github/…/ci.yml• L208-227 client/…/docker.sh• L8-28

Change checklist

When these files or sections are changed, remember to consider these:

  • Keep the names in examples.ts, the widget map in the manifest, and the baseline file names aligned. A renamed scenario changes the screenshot path.
  • Keep every visualization type in the example catalog aligned with its dashboard name and default widget size. A new type needs both seeded dashboard data and a browser test path.
  • Keep the Chinook database path visible to both the Redash worker and the seed configuration. A server that can see the file is not enough if the worker cannot read it.
  • Keep deterministic rendering rules aligned with new examples. Random layouts, time-relative text, and third-party assets can create false diffs.
  • Keep the Playwright image version aligned between local Docker runs and CI. Browser, font, and operating-system changes can invalidate every baseline.
  • Review baseline changes with the related visualization behavior. A snapshot update is part of the rendering contract, not a substitute for deciding whether the change is correct.

Important failure modes

TriggerConsequenceGuard
The Redash worker is not running or a query exceeds the seed timeoutThe seed stage cannot produce ready query results and no valid dashboard manifest is writtenStart the worker and check the server and worker logs before debugging image output
Custom JavaScript visualizations are disabledSeeding stops because the custom chart example cannot renderEnable REDASH_FEATURE_ALLOW_CUSTOM_JS_VISUALIZATIONS for the visual-test server
The SQLite file is not readable at the worker pathQueries fail during seeding and screenshots are never producedMount the repository at the expected container path or set VISUAL_TESTS_DB_PATH to a worker-readable path
The manifest is missing or staleThe browser stage cannot find the public dashboard or widget for a scenarioRun the seed project first and avoid --no-deps after changing examples
The test runs outside the Playwright Docker imageScreenshots differ because browser, fonts, or operating-system rendering differs from the baselineUse pnpm visual-tests:docker for comparison and baseline updates
A scenario name collides after slugificationTwo visualizations can map to the same baseline name, making the result ambiguousKeep names unique after conversion to lowercase dash-separated names
A third-party map tile or time-relative label changes between runsThe image diff reports noise instead of a product rendering changeKeep external tiles stubbed and dynamic labels hidden in the screenshot setup

Key files

FileWhy to read it
client/…/README.mdGives the supported commands, required service conditions, environment values, report location, and baseline rules.
client/…/playwright.config.tsDefines the seed-to-visual project dependency, browser viewport, image path, and screenshot comparison policy.
client/…/examples.tsDefines the stable query data and the visualization option scenarios covered by the suite.
client/…/seed.setup.tsShows how the examples become executed queries, visualizations, public dashboards, and widgets.
client/…/visualizations.spec.tsShows how the browser locates each widget, removes non-determinism, and compares its screenshot.
client/…/manifest.tsDefines the handoff from seeded dashboard resources to the browser test.
client/visual-tests/__screenshots__/Holds the accepted screenshot baselines grouped by visualization dashboard.
client/…/docker.shKeeps local visual comparisons in the same Playwright image used by CI.
.github/…/ci.ymlShows how CI starts Redash, runs the visual suite, and stores failure reports.
.ci/compose.cypress.yamlDefines the container settings shared by the visual-test Redash services, including custom visualization support.