我设置了一个jest starter,以便对使用jest-mongodb的内存中的mongodb运行集成测试
"jest": {
"preset": "@shelf/jest-mongodb",但是,运行npx jest得到的结果是
> 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如果我在没有jest-mongodb的情况下运行测试,它运行得很好。在我们的CI中,测试也将执行得很好。
> 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.我使用的是带有ubuntu子系统的Windows10。
节点版本13.9.0
npm版本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"
}你知道这里可能出了什么问题吗?
发布于 2020-08-26 15:27:23
好了,找到解决方案了。我是在正确的轨道上,错误是由ubuntu子系统引起的。在the github page for jest-mongodb找到了解决方案
Ubuntu缺少jest-mongodb所需的依赖项:
sudo apt-get install libcurl3 解决了它。
https://stackoverflow.com/questions/63591711
复制相似问题