-
Notifications
You must be signed in to change notification settings - Fork 10.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
getDocument hangs in Jest/JSDom environment #9579
Comments
As mentioned in both ISSUE_TEMPLATE.md and CONTRIBUTING.md: Without any context or code, the following questions comes to mind: Lines 129 to 130 in 0d391da
|
I've managed to deal with it! For those stuck like me, do NOT set |
The above solution didn't work for me, instead I had to configure jest to use node instead of jsdom (enabled by default) Adding this to the top of my spec file solved it
|
For me none of the above solutions are working. Im using vue-cli with jest tests |
This issue is a bit older, and I ran into different problems when running in Jest, though I got it working with a couple solutions:
Solution: Install a polyfill for
Solution: Conditionally configure the if (process.env.NODE_ENV !== 'test') {
pdfjs.GlobalWorkerOptions.workerPort = new PdfjsWorker();
} |
On PDF.js 2.0.385 and later, running the following simplest example:
runs fine on Node.js, obviously.
Running the same piece in Jest, as in this example (simplified, please ignore the fact the tests should be async):
testEnvironment
is set to"node"
, succeeds.testEnvironment
is set to"jsdom"
(default), hangs and never reaches.then()
.On PDF.js 2.0.305 and earlier this is not an issue, because you can easily disable workers manually.
Now that there's no way of doing that via config as of #9385, all projects using PDF.js and Jest/JSDom will be unable to test anything PDF.js-related. Switching
testEnvironment
to"node"
is usually not an option as this will cause virtually everything else on front-end to fail.The text was updated successfully, but these errors were encountered: