When I'm running cypress e2e tests, application makes XHR requests. How can I log all this requests and responses? I don't want to stub these requests. I with to get an artifact with all requests and responses made during test. Gitlab is used as CI.
Main test code looks like this. All these are user defined commands, interacting with the application. Interacting with the application causes different requests to be made (e.g. I click a button, this causes the request).
it('Log response to a file',function(){ cy.request({ method: 'GET', url: 'https://<site>/home/payments/currency/confirm/*', headers: { 'Content-Type': 'application/json', }, body: {}, }).then((response)=>{ const someResponse = response.body; console.log("hhhh"+someResponse); cy.writeFile('cypress/fixtures/testResponse.json', someResponse); cy.login(login_name, pass) cy.typeOTPpinpad(secret) cy.makePayment('Currency', 'amount') cy.typeToken(secret) cy.logout() }) }) Here is how I tried to use regular expression to catch request (id is unique and I need to use regular expressions).
https://<mysite>/home/payments/<currency>/confirm/* - asterisk is payment id. ![1]](https://i.sstatic.net/wREjd.png)