简体   繁体   English

使用猫鼬和打字稿进行测试:RangeError:超出最大调用堆栈大小 - node_modules/mongodb/src/bson.ts:38:3

[英]Testing with mongoose and typescript: RangeError: Maximum call stack size exceeded - node_modules/mongodb/src/bson.ts:38:3

I'm running tests with jest on a node/express application.我在 node/express 应用程序上用 jest 运行测试。 Anytime that I run anything with mongoose I get the following error:每当我用猫鼬运行任何东西时,我都会收到以下错误:

  ● 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)

When I've read other stackoverflow posts on this it tends to be an issue of iterating over multiple documents, but I still get an issue when I'm considering a single document:当我阅读有关此的其他 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);
  });

The fact that my console.log doesn't run at all makes me thing there's something wrong with mongoose/typescript.我的 console.log 根本没有运行的事实让我觉得 mongoose/typescript 有问题。 If I remove mongoose from the test it runs fine.如果我从测试中删除猫鼬,它运行良好。

The problem appears to have been with my jest.config.js file.问题似乎与我的jest.config.js文件有关。 I had moduleDirectories: ["node_modules", "src"], set.我有moduleDirectories: ["node_modules", "src"],设置。 When I commented this line out I no longer had the problem.当我评论这条线时,我不再遇到问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 RangeError:超出最大调用堆栈大小(MongoDB-mongoose) - RangeError: Maximum call stack size exceeded (MongoDB-mongoose) Node.js + mongoose [RangeError:超出最大调用堆栈大小] - Node.js + mongoose [RangeError: Maximum call stack size exceeded] 节点JS + MongoDB + Mongoose RangeError:超出最大调用堆栈大小错误 - Node JS + MongoDB + Mongoose RangeError: Maximum call stack size exceeded Error Mongoose - RangeError:超过最大调用堆栈大小 - Mongoose - RangeError: Maximum Call Stack Size Exceeded mongodb RangeError:超出最大调用堆栈大小 - mongodb RangeError: Maximum call stack size exceeded Node.Js 模块中变量和模块的范围导致 RangeError:超出最大调用堆栈大小 - Scope of variables and modules in Node.Js modules leading to RangeError: Maximum call stack size exceeded RangeError:Nodejs + Mongoose内置API超出最大调用堆栈大小 - RangeError: Maximum call stack size exceeded on Nodejs + Mongoose built API 猫鼬-推模型-RangeError:超出最大调用堆栈大小 - Mongoose - Push Model - RangeError: Maximum call stack size exceeded RangeError:最大调用堆栈大小超过Node.js猫鼬 - RangeError: Maximum call stack size exceeded Nodejs mongoose 聚合范围错误:超出最大调用堆栈大小(Node.js,猫鼬) - Aggregation RangeError: Maximum call stack size exceeded (Node.js, Mongoose)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM