Unable to require() to use with Jest
See original GitHub issueTypeError: Cannot read property 'prototype' of undefined
at ../../../../node_modules/c3/c3.js:2720:30
at ../../../../node_modules/c3/c3.js:3263:3
at Object.<anonymous>.CLASS.target (../../../../node_modules/c3/c3.js:2:82)
at Object.<anonymous> (../../../../node_modules/c3/c3.js:5:2)
which is
window.SVGPathElement.prototype.createSVGPathSegClosePath = function () {
I’m not quite sure where to report this. Jest, jsdom, here?
Issue Analytics
- State:
- Created 6 years ago
- Reactions:6
- Comments:13 (2 by maintainers)
Top Results From Across the Web
Unable to run JEST test - Stack Overflow
I'm facing an issue when I try to import something using require() function in jest test file. script2.test.js
Read more >Configuring Jest
If a given module's path matches any of the patterns, it will not be require() -able in the test environment. These pattern strings...
Read more >Configuring package.json · Jest
If you'd like to use your package.json to store Jest's config, the "jest" key should be used on ... it will not be...
Read more >Writing API Tests with Jest - Rithm School
We can do this from a TDD perspective so let's write some failing tests first! In our first.test.js file let's add: const letterCount...
Read more >Test runner with Nodejs and Jest not working with 17.1
Test run finished: 2 Tests (0 Passed, 2 Failed, 0 Skipped) run in 1,6 sec ... you need answers to common questions or...
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
@fernandes Got it. I played around with it a bit more and was able to run the snapshot tests by mocking c3:
and then in the Jest config portion of my
package.json
:@brandonros If you don’t need c3 functionality in your jest test cases, I think it’s ok to replace SVGPathElement with dummy object.
I was able to require c3.js in node environment by dummying window.SVGPathElement like the below: