marcdacz / compare-pdf

Standalone node module that compares pdfs
MIT License
62 stars 21 forks source link

Comparison byImage silently generates false positives when directory paths are not defined #11

Closed crizzis closed 3 years ago

crizzis commented 3 years ago

When using a partial config for byImage mode, i.e.:

new ComparePdf({ paths: { baselinePdfRootFolder: SNAPSHOTS_DIR, /* no values for actualPdfRootFolder, baselinePngRootFolder, actualPngRootFolder */ }, settings: ...),

The comparison passes even if the actual PDFs are different. This is because baselinePgnRootFolder and actualPngRootFolder both resolve to the literal string 'undefined', and so the tool ends up overwriting and comparing a PNG image with itself.

Instead, the tool could throw an error when one of the paths is undefined.

marcdacz commented 3 years ago

Nice catch. Will look into resolving this. Otherwise if you do have a solution ready, send a PR and I'd gladly review and merge.

Cheers Marc

marcdacz commented 3 years ago

Closing this issue now as I've added error handling in v1.1.5. Let me know if you find anything else. Thanks heaps