mocha, chai, Uncaught AssertionError: expected {} to equal {} + expected - actual [duplicate]

筅森魡賤 提交于 2019-12-18 19:21:28

问题


  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) Customers CRUD GET /customers/ with wrong id:

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

回答1:


You want to use deep if you're trying to compare objects:

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

Or use the eql method:

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


来源:https://stackoverflow.com/questions/38497731/mocha-chai-uncaught-assertionerror-expected-to-equal-expected-actua

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!