官方地址:https://github.com/roughsoft/jest-html-reporters
注意,是jest-html-reporters,不是jest-html-reporter
一、直接安装
npm install jest-html-reporters
二、在jest.config.js中添加配置文件
const moment = require('moment');
const date = moment(new Date()).format('YYYY-MM-DD-HH-mm-ss');
module.exports = {
testEnvironment: "node",
reporters:[
"default",
[
"jest-html-reporters",
{
"pageTitle":"Jest Report",
"filename":`./report/child/${date}.html`,
"expand":true
}
]
],
};
filename中的目录需要提前建好