Performance issue (?) with Drum Machine

Have built the Drum Machine project for Front End cert, and it’s functional, but cannot pass two of the tests (audio playing and text display).

I’m seeing an error saying there’s an uncaught DOMException when the tests are run, so clearly there’s something wrong with my code (or possible it’s a performance issue over the time to load samples?) but have been hacking at it for an hour and can’t see a way through.

Any help or advice appreciated!

Project is here: https://codepen.io/domwakeling/pen/bzRNjp?editors=1010

Fixing my own problem …

Turns out there was an issue with the audio.play() promise being blocked by a .pause() - I’m not entirely sure why it changes things, but:

  • before I was handling clicks on the drum pads by passing them to a this-bound clickHandler, which then activated a this-bound eventHandler, which internally called an unbound playAudio method
  • now the clicks are going straight to a this-bound playAudio method, and tests are all passing

(keyboard presses still going through the eventHandler but whether that’s tested or not, it’s not causing a fail)