【发布时间】:2016-09-04 15:49:48
【问题描述】:
我使用 findRenderedComponentWithType 来确保有错误,并且我使用 chai 的 assert.throws,但它不起作用。
首先:
TestUtils.findRenderedComponentWithType 文档:
expects there to be one result and returns that one result, or throws exception if there is any other number of matches besides one.
当我使用该功能时,我得到一个错误(如预期和正确)。
但是我似乎不能用 chai 正确地断言它:
我试过assert.throws(TestUtils.findRenderedComponentWithType(element, component), /(Error)/)。但它表示测试失败,即使我收到错误:
Error: Did not find exactly one match for componentType:function (props, context, updater) {
[...]
}
【问题讨论】:
标签: reactjs mocha.js chai reactjs-testutils