我正在进行以下测试,目前正在通过。当我运行npm test --coverage时,覆盖率仍然相同
这是测试文件:
it("should call button click", () => {
baseProps.onClick.mockClear();
baseProps.closeModal.mockClear();
wrapper.setState({
INITIAL_STATE:{},
});
wrapper.find('#BatchUpdate-testClick').simulate('click');
expect(baseProps.closeModal).toHaveBeenCalled();
});
这是代码:
<div className='security-search-wrapper-modal'>
<div className='fullmodal'>
<div className='fullmodal_title'>Batch Update</div>
<div title="Close Window" className="add-custom-field-close"
id='BatchUpdate-testClick' onClick={() => {this.closeModal()}}>
<FontAwesome name='xbutton' className='fa-times' /></div>
目标:由于当前测试通过,因此测试覆盖率提高了