首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在jest nodejs中配置`jest-html-reporter`‘

如何在jest nodejs中配置`jest-html-reporter`‘
EN

Stack Overflow用户
提问于 2018-06-06 06:28:50
回答 1查看 4.6K关注 0票数 1

我使用jest在nodejs项目中运行单元测试。当我运行yarn test时,测试用例正在运行,但没有生成报告。

代码语言:javascript
复制
"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文件中,但也不起作用。我还需要配置什么?

代码语言:javascript
复制
module.exports = {
  "globalSetup": "<rootDir>/src/globalSetup.js",
  "globalTeardown": "<rootDir>/src/globalTeardown.js",
  "testResultsProcessor": "./node_modules/jest-html-reporter"
}
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-08-02 14:38:29

尝试在package.json中添加下面的代码片段,就在jest配置的上方:

代码语言:javascript
复制
"jest-html-reporter": {
"pageTitle": "Unit Tests",
"outputPath": "./test-report.html",
"includeFailureMsg": true

}

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/50713549

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档