I am looking to convert all requests from cy.intercept()
into json
objects that include: {'method':'____', 'url':'____', 'response_time':'____'}
so that they can be written to a json
file for performance analysis.
I am currently able to show all of the request methods and URL’s but not their response times.
Current code to get network requests:
cy.intercept({method:'GET', url:'**'}).as('gets');
cy.intercept({method:'POST', url:'**'}).as('posts');
cy.visit('url');
Is it possible to iterate through these individual requests with their response times and save them within an array?
I have tried saving the value returned from intercept()
as a variable but it doesn’t show all of the requests or their response times.
var gets = cy.intercept({method:'GET', url:'**'}).as('gets');
var posts = cy.intercept({method:'POST', url:'**'}).as('posts');
cy.visit('url');
cy.writefile('file1.json', gets);
cy.writefile('file2.json', posts);
Thanks in advance.