当前位置: 动力学知识库 > 问答 > 编程问答 >

node.js - The followingbunch of test is executing perfectly except the update test

问题描述:

The following bunch of test is executing perfectly except the update test.

'describe.only('UsersModel', function() {

describe('#create()', function() {

it('should check create function', function (done) {

var newUser = { firstname: "fname", email: "[email protected]"};

User.create(newUser)

.then(function(results) {

// some tests

done();

})

.catch(done);

});

});

describe('#find()', function() {

it('should check find function', function (done) {

User.findAll()

.then(function(results) {

// some tests

done();

})

.catch(done);

});

});

describe('#update()', function() {

it('should check update function', function (done) {

User.update()

.then(function(results) {

// some tests

done();

})

.catch(done);

});

});

describe('#destroy()', function() {

it('should check destroy function', function (done) {

User.destroy()

.then(function(results) {

// some tests

done();

})

.catch(done);

});

});

});


> UsersModel

#create()

√ should check create function

#find()

1) should check find function

#update()

2) should check update function

#destroy()

√ should check destroy function

2 passing (46s)

2 failing

1. UsersModel #find() should check find function:

[Error (E_UNKNOWN) Encountered an unexpected error] Details: Error: In Waterline >= 0.9, findAll() has been deprecated in favor of find().

  1. UsersModel #update() should check update function:

    Error: timeout of 2000ms exceeded. Ensure the done() callback is being called in this test.

    at null.<anonymous> (C:\Users\acer\AppData\Roaming\npm\node_modules\mocha\lib\runnable.js:189:19)

网友答案:

Did you even read logs?

1) It says that findAll() has been deprecated in favor of find(). So you need to replace findAll() with find().

it('Should check find function', function (done) {
  User
    .find()
    .then(function(results) {
      // some tests
      done();
    })
    .catch(done);
});

2) Next. It says that "timeout of 2000ms exceeded. Ensure the done() callback is being called in this test". What about to call update() with parameters but not just empty function? What is Waterline need to update? You need to specify what to update and etc...

it('Should check update function', function (done) {
  User
    .update('<USER_ID>', {key: value})
    .then(function(results) {
      // some tests
      done();
    })
    .catch(done);
});
分享给朋友:
您可能感兴趣的文章:
随机阅读: