测试通过,但覆盖率未更新-Jest酶-React JS

时间:2019-03-06 15:46:44

标签: reactjs unit-testing jestjs enzyme

我正在进行以下测试,目前正在通过。当我运行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>

目标:由于当前测试通过,因此测试覆盖率提高了

0 个答案:

没有答案
相关问题