![](/img/trans.png)
[英]RangeError: Maximum call stack size exceeded (MongoDB-mongoose)
[英]Testing with mongoose and typescript: RangeError: Maximum call stack size exceeded - node_modules/mongodb/src/bson.ts:38:3
我在 node/express 应用程序上用 jest 运行测试。 每当我用猫鼬运行任何东西时,我都会收到以下错误:
● Test suite failed to run
RangeError: Maximum call stack size exceeded
at Object.get [as ObjectId] (node_modules/mongodb/src/bson.ts:38:3)
at Object.get [as ObjectId] (node_modules/mongodb/src/bson.ts:38:3)
(... line repeats total of 10 times)
当我阅读有关此的其他 stackoverflow 帖子时,它往往是迭代多个文档的问题,但是当我考虑单个文档时仍然遇到问题:
test("mongoose works", async () => {
console.log("this does not log") // Nothing logs and I get the "test suite failed to run" error
const findResponse = await UserAction.findOne({
action: "testString1",
}).exec();
expect(findResponse).toBe(false);
});
我的 console.log 根本没有运行的事实让我觉得 mongoose/typescript 有问题。 如果我从测试中删除猫鼬,它运行良好。
问题似乎与我的jest.config.js
文件有关。 我有moduleDirectories: ["node_modules", "src"],
设置。 当我评论这条线时,我不再遇到问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.