I am trying to run jest test with typescript + mongodb + mongoose and getting Maximum call stack size exceeded

212 views
Skip to first unread message

Shivam Gupta

unread,
Feb 21, 2022, 3:22:06 AM2/21/22
to Mongoose Node.JS ODM
 My test is failing in mongoose modules with following error
● Test suite failed to run
    RangeError: Maximum call stack size exceeded

      at Object.get [as ObjectId] (node_modules/mongoose/node_modules/mongodb/src/bson.ts:38:3)
      at Object.get [as ObjectId] (node_modules/mongoose/node_modules/mongodb/src/bson.ts:38:3)
      at Object.get [as ObjectId] (node_modules/mongoose/node_modules/mongodb/src/bson.ts:38:3)
      at Object.get [as ObjectId] (node_modules/mongoose/node_modules/mongodb/src/bson.ts:38:3)
      at Object.get [as ObjectId] (node_modules/mongoose/node_modules/mongodb/src/bson.ts:38:3)
      at Object.get [as ObjectId] (node_modules/mongoose/node_modules/mongodb/src/bson.ts:38:3)
      at Object.get [as ObjectId] (node_modules/mongoose/node_modules/mongodb/src/bson.ts:38:3)
      at Object.get [as ObjectId] (node_modules/mongoose/node_modules/mongodb/src/bson.ts:38:3)
      at Object.get [as ObjectId] (node_modules/mongoose/node_modules/mongodb/src/bson.ts:38:3)
      at Object.get [as ObjectId] (node_modules/mongoose/node_modules/mongodb/src/bson.ts:38:3)

  • I run the command : npm run test.
  • The test files starts executing and start visiting all the imports.
  • In my test file I am importing server from server.ts, which in turn is importing routes-> controllers->services->modals and this is failing in my modal file where I have below code:  import mongoose from "mongoose";



Reply all
Reply to author
Forward
0 new messages