Unit testing failure with Jest?
See original GitHub issueMy test suite will fail to run if I’m trying to test a component which uses vuepdf. This is with Jest on a project set up with vue-cli:
` ● Test suite failed to run
C:\frontend\uc-front\node_modules\vue-pdf\src\vuePdfNoSss.vue:1
({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,global,jest){<style src="./annotationLayer.css"></style>
SyntaxError: Unexpected token <`
I don’t get this error if I don’t import vue-pdf in the component.
Issue Analytics
- State:
- Created 6 years ago
- Comments:8 (1 by maintainers)
Top Results From Across the Web
In Jest, how can I make a test fail? - Stack Overflow
Method-1. You can wrap your promise function within expect and tell jest the function should reject with the given error. If the someOperation() ......
Read more >Troubleshooting - Jest
Use this guide to resolve issues with Jest. Tests are Failing and You Don't Know Why. Try using the debugging support built into...
Read more >Jest explicitly or arbitrarily force fail() a test - Code with Hugo
Output of the test run shows that if the code doens't throw, the test suite will fail, which is desired behaviour: FAIL src/fail-throws- ......
Read more >Successfully Throwing Async Errors with the Jest Testing Library
My mission now, was to unit test that when validateUploadedFile() threw an error due to some invalid import data, the setUploadError() function ...
Read more >How to find the root cause of a failing test if Jest doesn't tell ...
In our case, there's an option called --detectOpenHandles that solves our problem. By using this command, Jest should print the actual exception ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Came across the exact same problem. My solution:
adding to my jest.config.js:
made it work by adding vue-pdf and vue-resize-sensor to my jest config like following
jest.config.js
Then also in my my jest config I added a mocks for the worker like explained here https://github.com/wojtekmaj/react-pdf/issues/67#issuecomment-372118170
jest.config.js
create the following file ‘__mocks__/workerMock.js’ in you project and make the path above match it
workerMock.js