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.
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#L69These
Object.defineProperty
calls did not setconfigurable
toTrue
, which prevents the getter from being overridden. And that is whysinon.js
could not stub thepdfjsLib.getDocument
function.This fixes the test by overriding the
window.pdfjsLib
object and reverting it when the test is done.