jest-mongodb icon indicating copy to clipboard operation
jest-mongodb copied to clipboard

TypeError: Class extends value undefined is not a constructor or null

Open crobinson42 opened this issue 2 years ago • 8 comments

Jest v29 and this package v3 & v4 fail with all tests: image

TypeError: Class extends value undefined is not a constructor or null

      at Object.<anonymous> (node_modules/@shelf/jest-mongodb/lib/environment.js:15:70)
      at Object.newLoader (node_modules/pirates/lib/index.js:141:7)
      at ScriptTransformer.requireAndTranspileModule (node_modules/@jest/transform/build/ScriptTransformer.js:772:66)

Rolling back to v2 works as expected.

crobinson42 avatar Dec 03 '22 01:12 crobinson42

I'm getting the same "jest": "^26.6.3",

GeoFro avatar Dec 08 '22 18:12 GeoFro

Bumping this up.

stanyq4 avatar Feb 02 '23 18:02 stanyq4

Same here

stefdelec avatar Feb 09 '23 12:02 stefdelec

Updating jest-environment-node to the same version of jest fixed this for me. But now getting a different error.

bertmeeuws avatar Feb 23 '23 10:02 bertmeeuws

getting same error though.

mr-pinzhang avatar Mar 02 '23 10:03 mr-pinzhang

The problem is that the export TestEnvironment from jest-environment-node only exists after version v28. So either you'll need to upgrade your jest-environment-node, or downgrade jest-mongodb to v2.

mr-pinzhang avatar Mar 02 '23 10:03 mr-pinzhang

It's the same for me. image

xulsup avatar Apr 03 '23 08:04 xulsup

I have a monorepo with package depending on @shelf/jest-mongodb@"^4.1.7", and other package depending via a dependency on jest-environment-node@"^27.5.1". The @shelf/jest-mongodb@"^4.1.7" and jest-environment-node@"^27.5.1" both get hoisted up to the root node_modules.

Since the @shelf/jest-mongodb depends on the TestEnvironment export, which is not exported in the jest-environment-node@"^27.5.1", I believe the peerDependencies.jest-environment-node of "27.x.x || 28.x || 29.x" is incorrect.

For now I worked around this by adding devDependencies "jest-environment-node": "^29.5.0" to the root package.json.

kohtala avatar Jun 20 '23 08:06 kohtala