显示mocha + chai单元测试的详细信息

时间:2016-07-19 17:51:51

标签: node.js unit-testing mocha chai

我正在使用Mocha + Chai(带有ChaiAsPromised插件)来测试我的后端node应用程序。
我想测试某个单元中的错误。我希望得到undefined,并且在任何其他输出上失败。

例如:

  it('should fail creating without name', done => {
    var errors = models.Alias.build({
      AssociationId: faker.random.number()
    }).validate();
    expect(errors).to.eventually.not.exist.notify(done);
  })

如果测试失败,我会看到此输出:

1) Models: Alias should fail creating without name: AssertionError: expected { Object (name, message, ...) } to not exist

我希望显示有关Object和失败原因的更多详细信息。如何告诉mocha / chai打印Object字段和内容?

0 个答案:

没有答案