mocha,chai,Uncaught AssertionError:期望{}等于{} +期望 - 实际

时间:2016-07-21 07:29:32

标签: mocha chai

  it('GET /customers/ with wrong id', (done) => {
    request
      .get(`/customers/${wrongId}`)
      .end((err, res) => {
        expect(res.body).to.equals({});
        expect(res).to.have.status(404);
        done();
      });
  });

1)客户CRUD GET / customers / id id错误:

  Uncaught AssertionError: expected {} to equal {}
  + expected - actual

1 个答案:

答案 0 :(得分:28)

如果您要尝试比较对象,则需要使用deep

expect(res.body).to.deep.equal({});

或使用eql方法:

expect(res.body).to.eql({});