Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not working on Ubuntu 22.04 #351

Open
commoddity opened this issue Jun 7, 2022 · 4 comments
Open

Not working on Ubuntu 22.04 #351

commoddity opened this issue Jun 7, 2022 · 4 comments

Comments

@commoddity
Copy link

commoddity commented Jun 7, 2022

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.
jestjs/jest#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/@shelf+jest-mongodb@3.0.1_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/mongodb-memory-server-core@7.6.3/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
@luizgribeiro
Copy link

I've just run into this same issue.
Currently running on node:16-buster container

@commoddity
Copy link
Author

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

@mxlnk
Copy link

mxlnk commented Feb 8, 2023

I think upstream might be fixed, right? nodkz/mongodb-memory-server#732

#412

@armujahid
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

4 participants