shelfio / jest-mongodb

Jest preset for MongoDB in-memory server
MIT License
591 stars 83 forks source link

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

Closed crobinson42 closed 5 months ago

crobinson42 commented 1 year ago

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.

GeoFro commented 1 year ago

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

stanyq4 commented 1 year ago

Bumping this up.

stefdelec commented 1 year ago

Same here

bertmeeuws commented 1 year ago

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

mr-pinzhang commented 1 year ago

getting same error though.

mr-pinzhang commented 1 year ago

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.

xulsup commented 1 year ago

It's the same for me.

image
kohtala commented 1 year ago

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.