mercredi 7 novembre 2018

end() is not a function in a Node Mocha testing

I'm trying to test some services of my Nodejs API with mocha:

exports.getModelts = function(){
return new Promise((resolve, reject) => {
    Modelt.find(function(err, modelts) {
        if (err) {
            return reject(err);
          }
          return resolve(modelts);
    });
});

}

And the test:

  it('returns expected payload', function(done) {
service
  .getModelts()
  .end(function(err, res) {
    expect(res.body.length).to.eql(6);
    expect(res.body[0].text).to.eql('Todo 1');

    done();
  });

});

I get the error:

TypeError: service.getModelts(...).end is not a function

Any help would be appreciatte.

Thanks in advance.

Aucun commentaire:

Enregistrer un commentaire