Mongoose aggregation query fails in Jest/Mockgoose test, works elsewhere

前端 未结 2 579
谎友^
谎友^ 2020-12-07 03:13

I\'m trying to create some tests for my Mongoose models, and I can\'t figure out how to get the Jest/Mockgoose test to pass for a shorthand query/aggregation pipeline (see b

2条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-07 03:21

    I have faced similar kind of problem and after researching a lot I found that that it was due to older version of mongoose as earlier versions are not compatible with breaking changes in MongoDB 3.6 and above.

    I upgraded mongoose version one by one and I found that it works perfectly fine with mongoose version 4.12.2 or above (mongoose@4.12.2).

    You can upgrade your mongoose version by running following command:

    npm install mongoose@4.12.2
    

提交回复
热议问题