我想在mochawesome中查看cy.log()命令的输出。下面是代码
/// <reference types="cypress" />
describe("Cypress File Upload", function() {
it("File Upload test", () => {
cy.visit('https://the-internet.herokuapp.com/')
cy.get('a[href="/upload"]').click()
const file = 'example.json'
cy.get('#file-upload').click().attachFile(file)
cy.get('#file-submit').click()
cy.log(file)
cy.get('#uploaded-files').contains('example.json', {matchCase: true})
})
})生成的HTML显示cy.log(文件),尽管example.json是预期的

如何查看上述命令的输出?
发布于 2021-01-13 23:52:42
您可以使用addContext。在cypress/support/commands.js中,您必须将以下代码放入:
import addContext from 'mochawesome/addContext';
Cypress.Commands.add('addContext', (context) => {
cy.once('test:after:run', (test) => addContext({ test }, context));
});之后,您可以在测试中使用命令cy.adContext:
cy.get('p').invoke('text').then(($text) => {
cy.addContext($text);
});https://stackoverflow.com/questions/65702340
复制相似问题