node.js - 如何在 jest nodejs 中配置`jest-html-reporter`
问题描述
我用来jest
在我的 nodejs 项目中运行单元测试。当我运行时yarn test
,测试用例正在运行,但没有生成报告。
"scripts": {
"test": "yarn run test:dev tests",
"test:dev": "jest --config jest.config.js"
},
"dependencies": {
"jest": "^22.4.4",
"lodash": "^4.17.10",
"mongodb": "^3.1.0-beta4",
"test-utils": "^1.1.1"
},
"devDependencies": {
"jest-html-reporter": "^2.3.0"
},
"jest": {
"testResultsProcessor": "./node_modules/jest-html-reporter",
"pageTitle": "Test Report",
"outputPath": "./test-report.html"
}
我也尝试将配置放入jest.config.js
文件中,但它也不起作用。我还需要配置什么?
module.exports = {
"globalSetup": "<rootDir>/src/globalSetup.js",
"globalTeardown": "<rootDir>/src/globalTeardown.js",
"testResultsProcessor": "./node_modules/jest-html-reporter"
}
解决方案
package.json
尝试在上面的jest
配置中添加以下代码段:
"jest-html-reporter": {
"pageTitle": "Unit Tests",
"outputPath": "./test-report.html",
"includeFailureMsg": true
}
推荐阅读
- azure - 如何调用 azure web 作业并传递参数
- sharepoint - SPFolder.MoveTo 保留子文件夹的元数据,同时重置根文件夹的元数据
- python - Cython 为应该计算为 0.5 的表达式返回 0?
- android - PN532 模拟卡无法被 Android 手机读取
- pywinauto - 运行代码 python3.7 和 pywinauto 时 pywinauto 出错
- c# - 如何在不访问其他设置的情况下打开 Windows 10 毫秒设置特定页面
- javascript - 带有下拉菜单的 ASP.NET 表单中的验证控件
- python - seaborn rc中的font_scale vs font.size
- c# - 实例化 List 的派生类
在运行时使用反射 - javascript - 以角度从列表中删除项目