jest mockgoose - jest did not exit one second after the test run has completed

后端 未结 2 805
无人共我
无人共我 2021-01-05 20:04

I have a mongoose model:

var mongoose = require(\"mongoose\");

var transactionSchema = mongoose.Schema({
  category: { type: String, required: [true, \"Cate         


        
2条回答
  •  梦毁少年i
    2021-01-05 20:44

    The error means exactly what it says, done wasn't defined but it's used. And it isn't needed in case promises are used. Jest supports promises, a promise should be returned from a block in order to be properly handled:

    afterEach(() => mockgoose.helper.reset());
    

    If there's a problem with open handles as in this question, Mongoose can be explicitly disconnected with:

    afterAll(() => mongoose.disconnect());
    

提交回复
热议问题