为了使Instanbul忽略noop函数,我们可以使用/* istanbul ignore next */
中提到的here。
例如,您可以做类似的事情
const defaultContext = {
activeInput: null,
removeFocus: /* istanbul ignore next */ () => {},
focusInput: /* istanbul ignore next */ () => {},
}
或者您可以定义一个隔离的noop函数并在需要时重用
/* istanbul ignore next */
function noop() {}
const defaultContext = {
activeInput: null,
removeFocus: noop,
focusInput: noop,
}