I was on the latest version of Jest when I got the same error. I eventually realized there was a circular dependency in my source code. Resolving the circular dependency made my tests work again.
The output was cryptic, but in hindsight the stack trace gave me the clues I needed to see that there was a circular dependency issue. The problem was happening on the dist/index
file, then my source files, then my src/index
file. Here is what the output looked like, for an example:
FAIL src/smoke.test.js
● Test suite failed to run
TypeError: Cannot read properties of undefined (reading 'default')
259 | enumerable: true,
260 | get: function get() {
> 261 | return _button["default"];
| ^
262 | }
263 | });
264 | Object.defineProperty(exports, "Input", {
at Object.get [as Button] (dist/index.js:261:22)
at Object.RealButton (src/skeleton/InputSkeletons.js:45:57)
at Object.require (src/skeleton/index.js:4:1)
at Object.require (src/index.ts:45:1)
at Object.require (src/setupTests.js:4:1)