英文:
Cypress Cloud - Recording all network requests during a test
问题
我正在Jenkins上运行Cypress测试,录制这些测试,并在Cypress Cloud平台上查看录制的内容。
我可以查看测试的视频和截图。但是,我想要录制并查看测试期间发送的网络请求,并在Cypress Cloud中查看它们。
这是否可能?如果是的话,如何操作?
我找到的与Cypress Cloud和网络有关的所有信息都是关于拦截特定请求的,而我想要能够展示开发人员整个网络历史,而不是期望一个特定的请求。
谢谢。
英文:
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
答案1
得分: 3
以下是翻译好的部分:
答案在这里如何在Cypress中记录API请求中的特定字段。
使用middleware
选项进行拦截,以捕获所有内容。
这只是基本设置,您可以调整URL和位置来编写日志。
const intercepts = []
cy.intercept({ url: '*', middleware: true }, (request) => {
request.continue(response => intercepts.push({request, response}))
})
... 测试
after(() => {
cy.writeFile('cypress/network/intercepts.json', intercepts)
})
英文:
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)
})
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论