jest-mongodb
jest-mongodb copied to clipboard
Not working on Ubuntu 22.04
Version: 3.0.1
Noticing a specific error since upgrading my Ubuntu workstation to 22.04.
Noticed the issue reported on the Jest Github but it seems to be specific to this package. https://github.com/facebook/jest/issues/12892
Seems that this is Ubuntu-specific (and particularly this version as the tests ran fine before upgrading). Tested the exact same test code on my Mac OS laptop and it ran as expected.
Steps to reproduce
Running jest
in a file that's set up to use jest-mongodb
Expected behavior
Expect a test to run successfully
Actual behavior
Run a test and get the following error:
Error: Jest: Got error running globalSetup -
/home/ {...} /node_modules/.pnpm/@[email protected]_c2wninixuuc53zmb5wxoc3zebe/node_modules/@shelf/jest-mongodb/setup.js,
reason: Instance Exited before being ready and without throwing an error!
at MongoInstance.<anonymous>
(/home/ {...} /node_modules/.pnpm/[email protected]/node_modules/mongodb-memory-server-core/lib/util/MongoInstance.js:140:25)
jest.config.js
const { defaults: tsjPreset } = require('ts-jest/presets');
module.exports = {
preset: '@shelf/jest-mongodb',
verbose: true,
testTimeout: 100000000,
transform: tsjPreset.transform,
transformIgnorePatterns: ['^.+\\.js$'],
testMatch: ['**/?(*.)+(spec|test).ts?(x)'],
resetMocks: true,
};
jest.mongodb-config.js
module.exports = {
mongodbMemoryServerOptions: {
binary: { version: '4.0.3', skipMD5: true },
instance: { dbName: 'jest' },
autoStart: false,
},
};
Environment
OS: Pop!_OS 22.04 LTS (Ubuntu)
CPU: 12th Gen Intel® Core™ i9-12900K × 24
Binaries:
Node: 16.13.0
pnpm: 7.1.7
npmPackages:
jest: ^28.1.0 => 28.1.0
I've just run into this same issue.
Currently running on node:16-buster
container
For anyone else who winds up here, this isn't an issue with either Jest or the jest-mongodb plugin but with MongoDB's current incompatibility with Ubuntu 22.04.
Was able to fix the issue by installing MongoDB Community but had to manually install libssl1.1 which is not recommended for security reasons.
Seems this issue is known about by the Mongo team and they are actively working on a fix: https://www.mongodb.com/community/forums/t/installing-mongodb-over-ubuntu-22-04/159931
In the meantime, if you want to force install libssl1.1 to get this working, instructions are here: https://askubuntu.com/questions/1403619/mongodb-install-fails-on-ubuntu-22-04-depends-on-libssl1-1-but-it-is-not-insta
I think upstream might be fixed, right? https://github.com/nodkz/mongodb-memory-server/issues/732
https://github.com/shelfio/jest-mongodb/pull/412
This has been resolved.
You can use latest mongodb version by configuring jest-mongodb using jest-mongodb-config.js
module.exports = {
mongodbMemoryServerOptions: {
binary: {
version: '6.0.6',
skipMD5: true,
},
autoStart: false,
instance: {},
},
};
https://www.mongodb.com/community/forums/t/jest-mongo-and-ubuntu-22-04/208722/3?u=abdul_rauf