automeris-io / WebPlotDigitizer

Computer vision assisted tool to extract numerical data from plot images.
https://automeris.io
GNU Affero General Public License v3.0
2.67k stars 363 forks source link

Fixed file manager metadata loading test failures #267

Closed ewchow closed 3 years ago

ewchow commented 3 years ago

This test failure led me down a rabbit hole: As it turns out, the newer version of pdfjs switched over to the ESM style: https://github.com/mozilla/pdfjs-dist/blob/7bfceb110b9b27a09cc3d69f4907c59fd5561f0c/lib/pdf.js#L69

These Object.defineProperty calls did not set configurable to True, which prevents the getter from being overridden. And that is why sinon.js could not stub the pdfjsLib.getDocument function.

This fixes the test by overriding the window.pdfjsLib object and reverting it when the test is done.