SuperTest의 .end()
메서드를 사용하여 응답에 Chai 어설 션을 실행하는 Sails.js API 테스트 (모카 사용)가 있습니다.SuperTest에서 어설 션 오류시 모카 타임 아웃 방지?
어설 션 후에도 테스트의 done()
콜백을 호출하지만 어설 션 오류가 발생하면 테스트 시간이 초과됩니다.
나는 시도/마침내의 주장을 포장 할 수 있지만,이 구역질 조금 보인다 : 더 나은 방법이 처리에
var expect = require('chai').expect;
var request = require('supertest');
// ...
describe('should list all tasks that the user is authorized to view', function() {
it('the admin user should be able to see all tasks', function (done) {
var agent = request.agent(sails.hooks.http.app);
agent
.post('/login')
.send(userFixtures.admin())
.end(function (err, res) {
agent
.get('/api/tasks')
.expect(200)
.end(function (err, res) {
try {
var tasks = res.body;
expect(err).to.not.exist;
expect(tasks).to.be.an('array');
expect(tasks).to.have.length.of(2);
} finally {
done(err);
}
});
});
});
});
어떤 제안? 아마 Chai HTTP가 좋을지도 모릅니다.