JExcellence
JExcellence
Full-stack · Oldenburg
BACKEND · 5 MIN READ

Testing a library upgrade against recorded reports

How two real PrivaLint reports, recorded against a fake website, made the 0.11.0 upgrade testable, and why they stay out of the Docker image.
Justin EiletzNovember 30, 2026

The privacy check on jexcellence.de runs PrivaLint for every address it checks. Three places read the report the library returns: the check page, the report email and the PDF report. On 18 November 2026 the check moved from PrivaLint 0.10.0 to 0.11.0, and the report schema moved with it, from 1.5.0 to 1.6.0. This post shows how two recorded reports make an upgrade like that testable, and which two lines keep the recording out of production.

The problem: a format you do not own

If your code consumes another library's output, tests built on hand-written objects only check what you expect the library to return. When a new version changes a field, a rule or a piece of text, those tests stay green, because they have never seen the new version.

A real report helps, as long as it does not come from a real website. Real websites change between recordings, and then you cannot tell whether the library checks differently or the page looks different.

Real reports, made-up website

The scan service keeps a script in the repository for this: scan-service/src/fixtures/record-fixtures.ts. It runs real scans through the same runner the service uses in production. The scan does not reach the internet, though. A network adapter serves a small website from memory at https://fixture.example, with a typical set of problems:

  • a Cookiebot banner with "Ablehnen" (reject) and "Alle zulassen" (accept all)
  • a stylesheet from fonts.googleapis.com
  • a Google Tag Manager script that sends an analytics hit with consent already marked as granted
  • a third-party script that reads back a canvas, which PrivaLint counts as fingerprinting
  • four images from four different hosts
  • a newsletter form with a pre-ticked marketing consent box that posts to an http:// address
  • a legal notice whose details are still "to follow", and a privacy policy with the placeholder "[Firmenname]"

The script scans that site twice, once with the banner and once without:

It reads the version for the file name from the installed privalint/package.json. The result is report-0.11.0-cookiebot.json and report-0.11.0-no-banner.json, about 70 and 67 KB.

What the tests check

Both the scan service tests and the website tests read these two files. A few of the checks:

Schema and version

  • Both reports carry schema 1.6.0.
  • The service's user agent names exactly the installed PrivaLint version.
  • The version shown on the check page matches the one pinned in the scan service's package.json.

Rules and copy

  • The report lists 33 rules, and the website has a label and an explanation for each. A new rule without copy fails here.
  • In the report with a banner, fingerprinting, banner-keyboard, form-preticked-consent and mixed-content are among the rules with a finding, while banner-language has none. The consent summary reads "Ablehnen getestet (Cookiebot)".
  • In the report without a banner, the banner rules stay unchecked, with the reason that no supported banner was found. They do not show up as passed.

A detail only real data shows

Since PrivaLint 0.10.1, the fix hints carry the full address of a step-by-step guide for the consent tool in use. Before that, the hint said https://github.com/[redacted]. The service splits the address off the hint text and links it in the email. The test covers both: the full address from the real report and the redacted form from older versions. A hand-written test object would never have known about that change.

The upgrade itself

The move to 0.11.0 was one commit across 15 files. It pinned the new version, re-recorded the reports with the script and replaced the two 0.10.0 files. The tests that name the version and schema now point at 0.11.0 and 1.6.0.

So nobody has to reconstruct this next time, the scan service README spells it out: re-record with node src/fixtures/record-fixtures.ts, which needs Playwright's Chromium. Then point src/upgrade.test.ts, src/runner.test.ts and ../app/lib/scan-upgrade.test.ts at the new version and schema, and delete the old reports.

Two lines that keep the recording out of production

A follow-up commit the same morning added two things.

The reports stay out of the image

The service's Dockerfile copies the whole src folder into the image, and the reports live in src/fixtures. The .dockerignore already excluded the tests, but not their data:

The last line is new. Since then, neither the roughly 137 KB of test reports nor the recorder script end up in the image that runs scans in production.

The script only scans when you run it

The recorder starts its scans as soon as the file loads, so any module that imported it would trigger a scan too. A guard sits in front of the loop:

If the file is imported instead of run, it stops with a clear message before any browser starts.

For your own project

  • Record the library's real output, but against input you control.
  • Commit the recorder script and put the library version in the recording's file name.
  • Test the places where your code reads the output: schema, rule names, copy.
  • Write the steps for the next upgrade into the README.
  • Keep test data and the recorder out of the production image with .dockerignore.
  • Make a script with side effects refuse to run on import.
CONTENTS
testing
fixtures
vitest
docker
dockerignore
privalint
Did this article raise a question about a project of your own? A 30-minute conversation about it is free and non-binding.