すべきテスト:モカチャイがPass buthがここに現在のテストだではない
describe('/POST Register Page', function() {
it('it should register new user', function(/*done*/) {
chai.request(server)
.post('/auth/register')
.send(new_user_data)
.end(function(res) {
expect(res).to.have.status(2017);
// done();
})
})
})
私が最後にチェック、2017
など一切HTTPコードがありません、しかし、それはまだ渡し:
Registration
Get register page
GET /auth/register 200 6.989 ms - 27
✓ it should get register page
/POST Register Page
✓ it should register new user
2 passing (147ms)
私が欲しいです単純に何かを投稿してから返答を返し、返答で遊ぶことができます。私は何かが間違っているか、右、テストに合格するかどうかについては、仕事を得ることができない
1) Registration /POST Register Page it should register new user:
Error: Timeout of 3000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves.
:私はdone()
が含まれている場合
は、私は、タイムアウトエラーが発生します。
予想通り、この取得要求が通過しているものの:
describe('Get register page', function() {
it('it should get register page', function(done) {
chai.request(server)
.get('/auth/register')
.end(function(err, res) {
expect(err).to.be.null;
expect(res).to.have.status(200);
done();
})
})
})
を、私はこのモカ兼チャイ・チャイ-HTTPの事で新たなんだ、と経験は、これまでに奇妙です。
ありがとうございました。
あなたは 'done'コールバックを使用しないように計画している場合(あなたが約束を持っている場合、あなたはいけません)そしてちょうど' chai.request'を返します。 [Promise]機能(https://github.com/chaijs/chai-http#dealing-with-the-response---promises)が有効になっていることを確認してください。 – MarcoL