question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TypeError: Cannot read property 'prototype' of undefined when run in jest

See original GitHub issue
yarn 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:open
  • Created 3 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
josdejongcommented, Sep 16, 2020

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).

0reactions
josdejongcommented, Nov 10, 2020

Thanks for checking 👍

We’ll keep this issue open and have to do more digging then. Anyone able to help?

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found