dimanche 10 juillet 2016

React testing with Enzyme/Mocha - Audio is not defined

I am trying to build a test suite for my react application. A component in the application uses Audio:

const audio = new Audio('beep.wav');
audio.play();

which works in the browser but according to this, is not on node.js. So when I use enzyme to try to render the component it gives an error:

ReferenceError: Audio is not defined

I am new to testing, but is there a way to get around this? Can I somehow mock an object to take Audio's place? I am new to font-end/javascript unit testing so I am still trying to learn the tricks.

Aucun commentaire:

Enregistrer un commentaire