astefanutti / decktape

PDF exporter for HTML presentations
MIT License
2.19k stars 176 forks source link

test(snapshots): use pdf as snapshot #257

Closed nicojs closed 1 year ago

nicojs commented 1 year ago

Use PDFs as snapshots instead of *.png files. Snapshot PDFs are stored in the test/snapshot and should mimic the dir name in test/input (with .pdf). Updating snapshots works the same way: using the update-snapshots workflow.

In the CI pipeline now works as follows:

  1. Generate the snapshot screenshots to test/e2e.spec.ts-snapshots based on test/snapshot/{input-dir-name}.pdf.
  2. Generate the actual PDF to test/output/{input-dir-name}.pdf based on test/input/*.
  3. Compare each page in the actual PDF using the test/e2e.spec.ts-snapshots as snapshots
  4. When the CI pipeline fails, the pipeline will upload the playwright report as an artifact, so you can figure out what went wrong.

The 'Update snapshots' workflow now works as follows:

  1. Generate the actual PDF in the test/output/{input-dir-name}.pdf directory based on test/input/*.
  2. Remove (rm -rf) the test/snapshot directory.
  3. Move the test/output directory to test/snapshot.
  4. Commit all changes.
nicojs commented 1 year ago

@astefanutti I finally got around to implementing your suggestion from https://github.com/astefanutti/decktape/pull/254#pullrequestreview-1233880110

I started working on my old branch, which is why you see a long history in this PR. Let's squash merge this.

nicojs commented 1 year ago

This might help. I've squashed the commits.

astefanutti commented 1 year ago

Thanks!