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

[Bug]: Error: Jest: Got error running globalSetup - .../node_modules/@shelf/jest-mongodb/setup.js, reason: Instance Exited before being ready and without throwing an error #12892

Closed
jimmythecode opened this issue May 31, 2022 · 8 comments

Comments

@jimmythecode
Copy link

Version

28.1.0

Steps to reproduce

yarn init
jest --init

Follow the steps in the docs: https://jestjs.io/docs/mongodb

package.json:

{
  "name": "mongojest",
  "version": "1.0.0",
  "main": "index.js",
  "license": "MIT",
  "devDependencies": {
    "@shelf/jest-mongodb": "^3.0.1"
  },
  "scripts": {
    "test": "jest"
  },
  "dependencies": {
    "jest": "^28.1.0"
  }
}

'jest.config.js`:

module.exports = {
  coverageProvider: "v8",
  "preset": "@shelf/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/@shelf/jest-mongodb/setup.js, reason: Instance Exited before being ready and without throwing an error!
    at MongoInstance.<anonymous> (/home/jimmythecode/Code/mongojest/node_modules/mongodb-memory-server-core/lib/util/MongoInstance.js:140:25)
    at Object.onceWrapper (node:events:642:26)
...

Additional context

I created the minimal node app to get this running.

Environment

System:
    OS: Linux 5.15 Ubuntu 22.04 LTS 22.04 LTS (Jammy Jellyfish)
    CPU: (4) x64 Intel(R) Core(TM) i7-5600U CPU @ 2.60GHz
  Binaries:
    Node: 18.2.0 - /usr/bin/node
    Yarn: 1.22.19 - /usr/bin/yarn
    npm: 8.9.0 - /usr/bin/npm
  npmPackages:
    jest: ^28.1.0 => 28.1.0
@jimmythecode
Copy link
Author

I installed Ubuntu 20.04 instead and made some changes and it's now working. I'm afraid I can't be sure if it was just the Ubuntu change that fixed it or there were other changes.

@SimenB
Copy link
Member

SimenB commented Jun 1, 2022

If anything this is a bug report for the preset you're using, doesn't seem related to anything in this repo

@SimenB SimenB closed this as completed Jun 1, 2022
@SimenB SimenB closed this as not planned Won't fix, can't repro, duplicate, stale Jun 1, 2022
@andre2l2
Copy link

andre2l2 commented Jun 1, 2022

I'm using ubuntu 22.04 I get this problem too

@gervasioartur
Copy link

I'm using ubuntu 22.04 I get this problem too

I was having same error on Ubuntu 22, i just tried with a different OS like windows and it worked.

@commoddity
Copy link

+1 can confirm this seems to be specific to Ubuntu 22.04 and particularly this preset (tests work fine when preset turned off and also work fine on my Mac OS workstation).

Submitted an issue on the preset's repo: shelfio/jest-mongodb#351

@gervasioartur
Copy link

gervasioartur commented Jun 8, 2022

I was looking for solutions to this problem and I realized that it just didn't work because I didn't have mongodb server installed on my machine. after i installed mongodb server it worked perfectly.

it is working on: ubuntu 22.4

@commoddity
Copy link

I was looking for solutions to this problem and I realized that it just didn't work because I didn't have mongodb server installed on my machine. after i installed mongodb server it worked perfectly.

it is working on: ubuntu 22.4

Yes indeed, that does seem to have fixed the problem. That said, I did have to take some possibly less than ideal steps to get MongoDB Community Edition installed on Pop_OS 22.04 as MongoDB has no offical build for 22.04 at the time. In order to install MongoDB using the instructions provided I had to manually install libssl1.1 which is not recommended for security reasons.

tl;dr this isn't an issue with either Jest or the jest-mongodb plugin but with MongoDB's current incompatibility with Ubuntu 22.04.

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

@github-actions
Copy link

github-actions bot commented Jul 9, 2022

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 9, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants