I have a component including shaka player that I want to test with react test library which is based on jest.
...
<ShakaPlayer
autoPlay
src="http://xxxx/bbb/default/index.mpd"
/>
...
When running a test on this component, if I make a simplistic test async like this:
it( 'includes a Init button', async () => {
const { getByText } = render( <Home/> )
await waitFor( () =>
expect( getByText( /Init/i ) ).toBeVisible()
);
} )
Then shaka player is causing the test to fail:
EmeEncryptionSchemePolyfill: EME not found
at es (node_modules/shaka-player-react/dist/cjs.js:854:374)
console.debug
McEncryptionSchemePolyfill: MediaCapabilities not found
at ns (node_modules/shaka-player-react/dist/cjs.js:859:230)
...
this.target.addEventListener is not a function
TypeError: this.target.addEventListener is not a function
at new Qc (/Users/Ludo/dev/xxx/saas/xxx/webapp/node_modules/shaka-player-react/dist/cjs.js:228:473)
The blocking point is this exception: this.target.addEventListener is not a function
It's because the player is in jest which includes a headless brother. Does someone know how to make shaka player not explode in this test environment?