PDF generation · Implement

How to Test Generated PDFs in CI

Test schema compatibility, rendering success, PDF structure, and visual output without relying on manual checks alone.

For developer · 9 min · Reviewed Jul 31, 2026

Test the contract first

Keep representative JSON fixtures for each document type. Validate them against the staging template contract in CI.

Include valid fixtures and focused invalid fixtures for required fields, types, bounds, and array structures.

Test rendering separately

Generate a PDF from known data and assert a successful content type, non-empty body, and valid PDF signature. Do not treat a 200 response alone as proof that the layout is correct.

Extract semantic checks

Where tooling permits, extract text and verify stable identifiers, totals, page counts, or expected labels. Keep these assertions focused on business-critical output.

Use visual regression carefully

Render a deterministic fixture in a controlled browser environment and compare it with a reviewed golden image. Fix fonts, viewport, renderer version, time zones, and remote assets to reduce false differences.

Connect tests to promotion

Run the suite against staging, require review for intentional golden changes, and promote the same immutable version that passed.

Put this workflow into practice

Read validation documentation

Related guides