简体   繁体   中英

Jest Tests not running with jest-mongodb preset

I have a set up a the jest starter to get integration tests running against an in memory mongodb with jest-mongodb

  "jest": {
    "preset": "@shelf/jest-mongodb",

However, running npx jest all I get is

> jest-starter@1.0.0 test my/path/jest-starter
> jest

Determining test suites to run...(node:10769) ExperimentalWarning: Conditional exports is an experimental feature. This feature could change at any time

If I run the tests without jest-mongodb it runs fine. In our CI the tests also will execute fine.

> jest-starter@1.0.0 test /my/path/jest-starter
> jest

 PASS  ./index.spec.js
  ✓ adds 1 + 2 to equal 3 (3ms)
  ✓ adds 5 + 8 to equal 13

Test Suites: 1 passed, 1 total
Tests:       2 passed, 2 total
Snapshots:   0 total
Time:        5.503s
Ran all test suites.

I have Windows 10 with ubuntu subsystem.

node version 13.9.0

npm version 6.13.7

package.json:

"jest": {
    "transform": {
      "^.+\\.jsx?$": "babel-jest"
    },      
    "preset": "@shelf/jest-mongodb"
  },
  "dependencies": {
    "@shelf/jest-mongodb": "^1.2.2",
    "mongodb": "^3.6.0"
  },
  "devDependencies": {
    "@babel/core": "^7.7.7",
    "@babel/preset-env": "^7.7.7",
    "babel-jest": "^24.9.0",
    "jest": "^24.9.0"
  }

Any ideas what might be wrong here?

Okay, found the solution. I was on the right track, the error was caused by the ubuntu subsystem. Found the solution at the github page for jest-mongodb

Ubuntu is missing a dependency required by jest-mongodb:

sudo apt-get install libcurl3 

solved it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM