oreillymedia / cypress-playback

Automatically record and playback HTTP requests in Cypress.
BSD 3-Clause "New" or "Revised" License
12 stars 3 forks source link

Not all types of Images are captured #154

Closed zernie closed 2 months ago

zernie commented 2 months ago

Describe the bug

For some reason, only SVGs are captured by Cypress. I don't even see JPGs and WEBPs in Cypress

Is it due to some browser-level caching?

I have tried intercepting the requests and disabling the cache, but that didn't help.

cy.playback('GET', IMAGE_KIT_UGC_REGEX, {
    toBeCalledAtLeast: waitForImagesCount,
    matching: { ignores: ['port'] }
  })
    .intercept('GET', '**/*.{jpg,jpeg,png,webp,gif}', (req) => {
      req.headers['cache-control'] = 'no-store'
      req.headers['pragma'] = 'no-cache'
      req.headers['expires'] = '0'
    })
    .as('image')

Expected behavior

All sorts of images need to be captured

Screenshots image

Environment

Additional context Add any other context about the problem here.

zernie commented 2 months ago

Clearing the cache has indeed fixed the issue :)

https://stackoverflow.com/questions/77455384/how-to-intercept-an-image-request-using-cy-intercept