酶检查组件是否在 prop 类型上没有错误地安装

Enzyme check if component mounted without errors on prop types

我正在为一个组件创建集成测试以测试它的接口,我正在像这样安装它

const wrapper = shallow(<Component boolVal={()=>{}} />

Component 中,我将 boolVal prop 标记为布尔值,并且在安装时我收到了预期的警告:

`Warning: Failed prop type: Invalid prop `boolVal` of type `function` supplied to `Component`, expected `boolean`.`

这是正确的,但我希望测试失败。

请问如何存档?

根据 Dmitri 的回答,这是一个监视 console.error 的测试。当道具验证失败时测试失败:

describe.only('Test Component', () => {

    const sandbox = sinon.sandbox.create();

    beforeEach(function() {
        sandbox.spy(console, 'error');
    });

    it('mounts', function () {
        shallow(
            <Component boolVal={()=>{}} />
        );
        assert.isFalse(console.error.called);
    });

    afterEach(function() {
        sandbox.restore();
    });
});