摩卡咖啡,柴,未捕获的AssertionError:预期{}等于{} +预期-实际 [英] mocha, chai, Uncaught AssertionError: expected {} to equal {} + expected - actual

查看:300
本文介绍了摩卡咖啡,柴,未捕获的AssertionError:预期{}等于{} +预期-实际的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  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:

1) Customers CRUD GET /customers/ with wrong id:

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

推荐答案

您要使用 deep 如果您要比较对象:

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

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

或使用 eql 方法:

Or use the eql method:

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

这篇关于摩卡咖啡,柴,未捕获的AssertionError:预期{}等于{} +预期-实际的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆