Unit Test with Mongoose

前端 未结 4 1810
渐次进展
渐次进展 2021-01-01 17:21

I\'m new to Node.js, Mongoose, and testing in this environment. I have the following schema declared in a separate file.

Issue = mongoose.model(\"Issue\", {         


        
4条回答
  •  我在风中等你
    2021-01-01 18:22

    Mongoose model (your Issue) returns a new instance of the Query object. The new query instance has access to the exec method through the prototype. (mongoose 3.8~)

    If you want to return an error you can write:

    sinon.stub(mongoose.Query.prototype, "exec").yields({ name: "MongoError" }, null);
    

提交回复
热议问题