CodeceptJS学习笔记-入门05-生成HTML测试报告

 
 

安装mochawesome

npm i mochawesome

如果有以下报错

"mochawesome" reporter not found
 
invalid reporter "mochawesome"

执行安装命令

npm i mocha -D


codeceptjs.conf.js文件中加入

mocha: {
    reporterOptions: {
        reportDir: "output"
    }
  },

运行,执行命令

npx codeceptjs run --reporter mochawesome

生成测试报告mochawesome.html

全部内容

const { setHeadlessWhen } = require('@codeceptjs/configure');
 
 
// turn on headless mode when running with HEADLESS=true environment variable
// HEADLESS=true npx codecept run
setHeadlessWhen(process.env.HEADLESS);
 
  tests: './*_test.js',
  output: './output',
  helpers: {
    Puppeteer: {
      url: 'https://url.com',
      show: true,
      windowSize: '1920x1080'
    }
  },
  include: {
    I: './steps_file.js'
  },
  bootstrap: null,
  mocha: {},
  name: 'codeceptdemo',
  translation: 'zh-CN',
  mocha: {
    reporterOptions: {
        reportDir: "output"
    }
  },
  plugins: {
    retryFailedStep: {
      enabled: true
    },
    screenshotOnFail: {
      enabled: true
    }
  }
}
原文地址:https://www.cnblogs.com/7047-zfy/p/13231525.html