test('componentWillUnmount should clear the timer', () => { const wrapper = shallow(); const instance = wrapper.instance(); jest.spyOn(global, 'clearTimeout');

instance.componentWillUnmount();

expect(global.clearTimeout).toHaveBeenCalledWith(instance.timer);

});

输入Jest单元测试:componentWillUnmount clearTimeoutthistimer;

原文地址: https://www.cveoy.top/t/topic/hJkW 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录