如何配置package.json为开玩笑的测试用例生成诱人的报告?

时间:2019-06-18 09:18:56

标签: jestjs allure

我使用笑话进行API测试。我正在使用jest-html-reporter生成html报告,但是我需要更改报告以吸引人。如何配置package.json文件以生成吸引力报告?我只使用package.json而未使用任何其他配置文件。

package.json

{
  "name": "reatapitesting",
  "version": "1.0.0",
  "description": "Ecommerce Testing Library",
  "main": "index.js",
  "directories": {
    "test": "test -verbose"
  },
  "repository": {
    "type": "git",
    "url": "https://git.techardors.com/pradeep/ecomm_testing.git"
  },
  "keywords": [
    "Ecommerce",
    "API",
    "Testing"
  ],
  "author": "TA-Testing Team",
  "license": "ISC",
  "scripts": {
    "test": "jest --testResultsProcessor=jest-html-reporter"
  },
  "jest": {
    "verbose": true,
    "testResultsProcessor": "jest-html-reporter"
  },
  "jest-html-reporter": {
    "pageTitle": "Your test suite",
    "outputPath": "./src/test-report.html",
    "includeFailureMsg": false
  },
  "dependencies": {
    "bson": "^4.0.2",
    "jest": "^24.8.0",
    "jest-allure": "^0.1.1",
    "jest-html-reporter": "^2.5.0",
    "supertest": "^4.0.2"
  }
}

1 个答案:

答案 0 :(得分:0)

要在Jest中包含Allure报告,我们必须添加'jest-allure'依赖项

npm:   npm install --save-dev jest-allure

在package.json的下面,添加以下内容

"setupFilesAfterEnv": ["jest-allure/dist/setup"]

要生成报告,请运行'allure serve'

或在脚本"report": "allure serve"中添加以下内容 您可以使用npm run report

运行