【问题标题】:mocha, chai, Uncaught AssertionError: expected {} to equal {} + expected - actual [duplicate]mocha,chai,Uncaught AssertionError:预期 {} 等于 {} + 预期 - 实际 [重复]
【发布时间】:2016-11-24 15:53:56
【问题描述】:
  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) 客户 C​​RUD GET /customers/ id 错误:

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

【问题讨论】:

    标签: mocha.js chai


    【解决方案1】:

    如果你想比较对象,你想使用deep:

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

    或者使用eql方法:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-04-19
      • 1970-01-01
      • 2023-02-03
      • 2017-12-06
      • 2020-09-21
      • 2019-08-27
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多