Javascript Cypress-在控制台和日志文件上打印-Windows

Javascript Cypress-在控制台和日志文件上打印-Windows,javascript,cypress,Javascript,Cypress,我运行Windows10,在Cypress上创建了一个项目,我想在文件和控制台上记录测试结果:我尝试在文件上打印,在我的package.json中使用此脚本: "scripts": { "open": "./node_modules/.bin/cypress open", "runheadless": "./node_modules/.bin/cypress run --h

我运行Windows10,在Cypress上创建了一个项目,我想在文件和控制台上记录测试结果:我尝试在文件上打印,在我的
package.json中使用此脚本:

"scripts": {

        "open": "./node_modules/.bin/cypress open",
        "runheadless": "./node_modules/.bin/cypress run --headless --browser chrome
         --spec 'cypress/integration/webpages.spec.js' > cypresstest.log"
      }
而且运行平稳,;我的问题是有100多个测试,需要很长时间(比如20分钟);所以我无法检查是否有东西冻结或工作正常,因为控制台上并没有打印任何内容

所以我试过了

"runheadless": "./node_modules/.bin/cypress run --headless --browser chrome
         --spec 'cypress/integration/webpages.spec.js' | tee cypresstest.log"
但因为我在windows上,它说

tee is not recognized as internal or external program
有没有一种方法,或者插件,或者我可以做些什么来简单地在控制台和文件日志上打印?

有这样的功能,或者您可以使用自定义命令,包括而不是cy.log-例如:

cypress插件文件

module.exports = (on, config) => {
   on('task', {
        log (message) {
            console.log(message)

            return null
        }
    })
}
自定义命令:

Cypress.Commands.add("logInAndOut", (message) => {
    cy.log(message)
    cy.task('log', message)
});
测试文件

cy.logInAndOut('My log')
编辑:我找到了另一个解决方案-,我将列出一个示例,但我不推荐它,因为如果其他人尝试在您之后使用该代码-将不知道更改:

Cypress.Commands.overwrite('log', (originalFn, message, args...) => {
  console.log(message, args...)

  // originalFn is the existing `log` command that you need to call
  // and it will receive whatever you pass in here.
  //
  // make sure to add a return here!
  return originalFn(message, args...)
})

谢谢,我会试试这个插件!我改进了我的建议,因为我尝试了它,它开始只在控制台上显示第三个选项如何做。好吧,我终于尝试了插件,但遗憾的是没有做到我想做的:它打印一个json(或类似)文件和一个错误的简历,但遗憾的是它没有准确打印出它在终端上打印的内容;此外,由于一些奇怪的原因,如果我尝试在我的项目中使用cypress接口而不是headless,它将永远循环。我将尝试您的自定义建议。根据其他用户的说法,这应该可以解决您的问题:自定义命令:
Cypress.Commands.overwrite('log',(subject,message)=>cy.task('log',message))=>plugins/index.js中的事件:
on('task',{log(message){console.log(message);returnnull;}}})