我有一个jest starter的设置,可以使集成测试针对使用jest-mongodb的内存mongodb运行
"jest": {
"preset": "@shelf/jest-mongodb",
但是,仅凭运行npx就可以了
> 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子系统的Windows 10。
节点版本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"
}
任何想法在这里可能出什么问题吗?
答案 0 :(得分:0)
好的,找到了解决方案。我在正确的轨道上,该错误是由ubuntu子系统引起的。在the github page for jest-mongodb
找到了解决方案Ubuntu缺少jest-mongodb所需的依赖项:
sudo apt-get install libcurl3
解决了。