0

I am running cypress tests on Jenkins, recording the tests, and viewing the recording on the Cypress Cloud platform.

I can view a video and see a screenshot of the tests. However, I would like to be able to record and view the Network requests sent during the test, and view them in the Cypress Cloud.

Is it possible? If so, how?

All information I found related to the Cyperss Cloud and the network was about intercepting specific requests, and I want to be able to show devs the whole network history without expecting one specific request.

Thanks

Pasquale
  • 33
  • 4

1 Answers1

3

The answer is here How do I log a specific field in API requests within Cypress.

Use the middleware option to make an intercept that captures everything.

This is bare-bones, you will fine tune things like URL, location to write the log.

const intercepts = []

cy.intercept({ url: '*', middleware: true }, (request) => {
  request.continue(response => intercepts.push({request, response}))
})

... testing

after(() => {
  cy.writeFile('cypress/network/intercepts.json', intercepts)
})
Pasquale
  • 33
  • 4
  • That's great for recording the network and creating a local file. But how do I upload this file to the Cypress Cloud? My intention is that after a test ran in Jenkins, and a file was created with the network requests, the developer will be able to view this file in the Cypress Cloud – Dean Nates May 08 '23 at 08:21