question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Feature request: High-level way to assert whether the browser is playing an audio file

See original GitHub issue

Current behavior:

No high-level ability to test whether the browser is playing an audio file.

Desired behavior:

If possible, it’d be great to have a high-level way to check whether a specific audio file is currently being played by the browser, whether by an <audio> tag, the web audio API, or some other method that I don’t know about.

This could be something like cy.audio('https://example.com/path/to/music/file.mp3').should('be.playing').

My app uses howler JS to play audio files, and all I’ve been able to come up with in terms of testing the music is to use cy.window() to access the Howler global. This works okay, but it’d be great if there was a better way to do this that wasn’t so tied to the specific tool I’m using.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:5
  • Comments:15 (5 by maintainers)

github_iconTop GitHub Comments

9reactions
kucebcommented, May 21, 2018

@nwshane you can use this if you want to ensure audio is playing for the client…if you we’re using audio or video elements.

const expectPlayingAudio = () => {
  cy.get('audio,video').should((els)=>{
    let audible = false
    els.each((i, el)=>{
      console.log(el)
      console.log(el.duration, el.paused, el.muted)
      if (el.duration > 0 && !el.paused && !el.muted) {
        audible = true
      }

      // expect(el.duration > 0 && !el.paused && !el.muted).to.eq(false)
    })
    expect(audible).to.eq(true)
  })
}

describe('page', () => {
  it('works', () => {
    cy.visit('/')
    expectPlayingAudio()
  })
})
7reactions
illrightcommented, Feb 24, 2022

@jennifer-shehane Could we reopen this? Seems like a valid feature request that is still not implemented

Read more comments on GitHub >

github_iconTop Results From Across the Web

HighLevel Support Portal: Solutions
Why are my email links changing and how to fix links in the email that do not open? Mailgun error: too many requests....
Read more >
Setting up your own test automation environment
To show how to set up a Selenium testing environment locally and run tests with it, and how to integrate it with tools...
Read more >
Try out our new features page - Chrome Platform Status
This feature enables a standard way for a page which embeds content in frames to request performance timeline entries from those frames, and...
Read more >
MediaPlayer - Android Developers
onError() method if an OnErrorListener has been registered beforehand via ... standard or file spec, but the media framework does not support the...
Read more >
Understanding Conformance | Understanding WCAG 2.0 - W3C
Usability testing aims to determine how well people can use the content for ... from being classified as conforming if the checkout or...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found