我正在尝试编写一些单元测试来测试使用Cloud Code实现的一些功能。以下是我的代码。但是,似乎Mocha不会等到收到Cloud Code响应并立即退出测试:
var chai = require('chai');
var expect = chai.expect;
var Parse = require('parse/node').Parse;
Parse.initialize("", "");
describe('MyTest', function() {
it('Number of cart items should be greater than 0', function() {
var cartSummary = 0;
var CartItem = Parse.Object.extend('CartItem');
var query = new Parse.Query(CartItem);
query.find({
success: function(results) {
expect(results).to.have.length(3);
},
error: function(error) {
console.log("Error: " + error.code + " " + error.message);
}
});
});
});