How do you use Jest to test img.onerror
问题 I've created a React component that loads an image and determines if the image loaded successfully or not. import React from 'react'; import PropTypes from 'prop-types'; import { LOADING, SUCCESS, ERROR } from '../helpers'; class Image extends React.Component { static propTypes = { onError: PropTypes.func, onLoad: PropTypes.func, src: PropTypes.string.isRequired, } static defaultProps = { onError: null, onLoad: null, } constructor(props) { super(props); this.state = { imageStatus: LOADING };