shelfio / jest-mongodb

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

Breaking change in 4.1.0: can't require @shelf/jest-mongodb/setup #378

Closed ArthurHoaro closed 1 year ago

ArthurHoaro commented 1 year ago

I use a simple jest setup script to perform a few bootstrap operations (init, load fixtures, etc.), based on #212, something like this:

const mongoSetup = require('@shelf/jest-mongodb/setup');

module.exports = async() => {
    await mongoSetup();

    // Do stuff with MONGO_URL
};

Unfortunately, this no longer works with the release v4.1.0, but it did work with v4.0.0. The following error is now thrown:

Error: Jest: Got error running globalSetup - /home/<path>/jest-setup.js, reason: Cannot find module '@shelf/jest-mongodb/setup'

I don't mind updating my script if it's an expected behavior, but since it does not seem to be documented, I'm not sure what's the best way to handle it.

 ➜ node -v     
v16.17.0
 ➜ npm -v      
8.15.0
vladholubiev commented 1 year ago
const mongoSetup = require('@shelf/jest-mongodb/lib/setup');

Have you tried this?

ArthurHoaro commented 1 year ago

I did not, and it's working fine! Thank you! I suppose it's because the build has changed with TS support.

It could be worth mentioning it in the release note.