TypeError: Cannot read property 'prototype' of undefined when run in jest
See original GitHub issueyarn jest --testPathPattern path/to/file
yarn run v1.22.4
$ D:\workspace\js\myproject\node_modules\.bin\jest --testPathPattern path/to/file
FAIL path/to/xxx.spec.ts
● Test suite failed to run
● Test suite failed to run
TypeError: Cannot read property 'prototype' of undefined
at Object.<anonymous>.createComplexClass.isClass (node_modules/mathjs/lib/type/complex/Complex.js:28:23)
at assertAndCreate (node_modules/mathjs/lib/utils/factory.js:49:12)
at Object.<anonymous> (node_modules/mathjs/lib/entry/pureFunctionsAny.generated.js:24:38)
at Object.<anonymous> (node_modules/mathjs/lib/entry/mainAny.js:53:25)
It can be produced with the latest at least three versions. It works fine in my project when run the project by running npm run start
. Why this is not working with jest.
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
Cannot read property 'prototype' of undefined in jest test ...
I've seen this error before. When exporting a component as a class, you have to import the component into your test as an...
Read more >TypeError: Cannot read property 'prototype' of undefined #709
My first idea would be to try and declare a custom babel config that is only used with your tests. So in your...
Read more >Cannot read property 'prototype' of undefined in jest test-Reactjs
I've seen this error before. When exporting a component as a class, you have to import the component into your test as an...
Read more >Typeerror: Cannot Read Property 'Prototype' Of Undefined
Jammming TypeError: Cannot Read Property map of undefined I am encountering this TypeError all the time no matter how many times I try...
Read more >es6 classes: Cannot read property 'prototype' of undefined
I've modified koa example to use es6 classes, but when I run it chrome I got this error Here is a link to...
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
Thanks a lot for working out this example David!
We’re working on improved support for ES modules and Commonjs in the library (see #1941, #1962), it will be interesting to see if we can solve this issue with Jest (or maybe it’s even already fixed in this PR).
Thanks for checking 👍
We’ll keep this issue open and have to do more digging then. Anyone able to help?