【发布时间】:2017-01-11 18:54:25
【问题描述】:
我正在尝试测试是否调用了 componentWillMount,为此我的测试是
test('calls `componentWillMount` before rendering', () => {
let fn = jest.fn(SomeComponent.prototype.componentWillMount)
mount(<SomeComponent />)
expect(fn).toHaveBeenCalled()
})
但是即使调用了 componentWillMount 方法,测试也没有通过。 我在这里错过了什么?
【问题讨论】:
标签: unit-testing reactjs jestjs enzyme