猜期望行为不清楚

时间:2018-11-15 18:21:45

标签: node.js mocha chai

我有一个预期会失败的测试用例。

expect.fail('Not Found');

Tes失败,但错误消息在本地和Heroku服务器上错误地填充

在本地

{ AssertionError: expect.fail()
    at Object.<anonymous> ()
    at next (native)
    at fulfilled (58)
  message: 'expect.fail()',
  showDiff: false,
  **actual: 'Not Found',**
  expected: undefined,
  operator: undefined }

在Heroku上

{ AssertionError: Not Found
  **message: 'Not Found',**
  showDiff: false,
  actual: undefined,
  expected: undefined,
  operator: undefined }

当我断言时

expect(err.message).to.eql('Not Found');

在本地传递但在服务器上失败!知道这里可能有什么问题

1 个答案:

答案 0 :(得分:0)

尝试以下操作:expect.fail(err.message, 'Not Found', 'It Throws a failure.')