2

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?

2
  • Hello! Did you ever get through this?
    – Marcox
    Commented Aug 23 at 21:37
  • @Marcox yes I completely mocked ShakaPlayer
    – unludo
    Commented Oct 7 at 16:27

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.