如何获取使用Jest执行的测试的HTML报告?

pieyvz9o  于 8个月前  发布在  Jest
关注(0)|答案(1)|浏览(85)

测试执行后,我在控制台得到结果。现在我需要HTML格式的相同结果。我们如何得到HTML报告格式的测试结果?

ttisahbt

ttisahbt1#

您可以添加jest-html-reporter

{
  "name": "api_ts_tests",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "build": "tsc"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "@types/jest": "^29.5.3",
    "axios": "^1.4.0",
    "jest": "^29.6.2",
    "jest-html-reporter": "^3.10.2",
    "ts-jest": "^29.1.1",
    "typescript": "^5.2.2"
  },
  "dependencies": {
    "@actions/core": "^1.10.1",
    "@actions/github": "^5.1.1",
    "js-yaml": "^4.1.0"
  },
  "jest": {
    "transform": {
      "^.+\\.ts$": "ts-jest"
    },
    "testMatch": [
      "**/?(*.)+(spec|test).[t]s?(x)"
    ],
    "reporters": [
      "default",
      [
        "./node_modules/jest-html-reporter",
        {
          "pageTitle": "Test Report"
        }
      ]
    ]
  }
}

字符串
调整html报告的参数列表-> https://github.com/Hargne/jest-html-reporter/wiki/configuration#list-of-configuration-options

相关问题