UNPKG

@fakes/media-devices

Version:

A interactive fake implementation of MediaDevices interface in the browser for testing

22 lines (19 loc) 496 B
export {} declare global { namespace jest { interface Matchers<R> { toIncludeVideoTrack(): CustomMatcherResult } } } expect.extend({ toIncludeVideoTrack(received: MediaStream): jest.CustomMatcherResult { const videoTracks = received.getTracks().filter((track) => track.kind === 'video') const pass: boolean = videoTracks.length > 0 const message: () => string = () => (pass ? '' : `includes no video track`) return { message, pass, } }, })