gpt4 book ai didi

express - Jest 错误 : Mongoose: looks like you're trying to test a Mongoose app with Jest's default jsdom test environment

转载 作者:行者123 更新时间:2023-12-05 08:14:30 26 4
gpt4 key购买 nike

使用 Mongoose 中间件测试 ExpressJS 的 Jest 端点时遇到以下错误:

Mongoose: looks like you're trying to test a Mongoose app with Jest's default jsdom test environment. Please make sure you read Mongoose's docs on configuring Jest to test Node.js apps: http://mongoosejs.com/docs/jest.html

问题是什么?

最佳答案

"scripts": {
"test": "jest --testEnvironment=node --verbose --forceExit --watchAll --maxWorkers=1"
}
  1. 如上所示将 --testEnvironment=node 添加到 package.json。
  2. 然后重新运行“npm test”

问题已解决!

关于express - Jest 错误 : Mongoose: looks like you're trying to test a Mongoose app with Jest's default jsdom test environment,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59223433/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com