-
-
Notifications
You must be signed in to change notification settings - Fork 882
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
How to setup worker in unit test in Create-React-App? #729
Comments
You won't be able to run external worker in unit tests. For unit tests, I'd suggest using You could use |
The
{
"jest": {
"moduleNameMapper": {
"^react-pdf$": "react-pdf/dist/umd/entry.jest"
}
}
} Thanks @wojtekmaj |
Well the above did indeed work, to some extend at least, for me as well. But now I'm getting this issue:
|
I got this issue after @MaStr11 soluction
|
This issue is stale because it has been open 90 days with no activity. Remove stale label or comment or this issue will be closed in 14 days. |
This issue was closed because it has been stalled for 14 days with no activity. |
This solution has worked for me as well, the only thing I had to change though is this: "jest": {
"moduleNameMapper": {
"^react-pdf": "react-pdf/dist/umd/entry.jest"
}
}, I.e. removed import { Document, Page } from "react-pdf/dist/esm/entry.webpack";`) |
Hi @wojtekmaj , I'm still getting the same issue eventhough I set the module mapper in Jest config. Please advise. package.json
Jest.config.js
|
the solution above also not work when I use NextJS. |
My solution is change the code a bit
|
What are you trying to achieve? Please describe.
Run a test that loads a pdf from local file in a CRA app.
Describe solutions you've tried
I have tried putting the following at the top of my unit test file
but i get the following error
Environment
"react-scripts": "^4.0.1",
"react-pdf": "^5.1.0",
"react": "^17.0.1",
The text was updated successfully, but these errors were encountered: