【发布时间】:2019-01-20 14:18:55
【问题描述】:
在我的组件中,我有这样的代码:
this.videoRef.current.pause();
videoRef 是 <video ref={this.videoRef} autoPlay muted > ...
当 Is pause 在测试中达到时,我收到错误:
Error: Not implemented: HTMLMediaElement.prototype.pause
如何模拟暂停功能?
const wrapper = mount(<ComponentWithVideoTag />);
const el = wrapper.find('video').props();
Object.defineProperty(el, 'paused', {
writable: true,
value: jest.fn(),
});
不适合我。
【问题讨论】: