title: How to make Chrome and/or Firefox play <audio> elements in Karma tests?
body: <p>I'm working on a library that can extract audio from HTML5 <code>&lt;audio&gt;</code> and <code>&lt;video&gt;</code> elements and send it to a remote server for speech-to-text processing. (e.g. automatic subtitles.) When I test manually, everything works as expected, but when karma runs my test, it always fails for <code>&lt;audio&gt;</code> elements.  </p>
  
  <p>For context, HTML5 <a href="https://developer.mozilla.org/en-US/docs/Web/API/AudioContext/createScriptProcessor" rel="nofollow">audio script processors</a> immediately get a stream of audio as soon as they are connected to an <code>&lt;audio&gt;</code> element, but it's all 0's (no sound) until the element begins playing. </p>
  
  <p>When my tests run in karma, it appears that the element never begins playing; I just get 0's even though I've called <code>.play()</code> on the element. Also, I don't hear any audio coming out of my speakers, which should happen at the same time.</p>
  
  <p>(I get that audio during tests could be super-annoying and probably <em>should</em> be disabled by default, but is there a way to enable it for cases like mine?)</p>
  
  <p>If you're interested in seeing the code, it's at <a href="https://github.com/watson-developer-cloud/speech-javascript-sdk" rel="nofollow">https://github.com/watson-developer-cloud/speech-javascript-sdk</a> but it's still a bit of a mess, and is currently configured to skip the tests that would fail. If necessary, I'll try and set up a stripped down example, but I'm hoping I won't need to.</p>
  
  <p>I'm on OS X if it makes a difference. I haven't tried this on Windows or Linux yet.</p>