在 TeamCity 中显示 Spectron-Webdriverio 测试结果

Displaying Spectron-Webdriverio test results in TeamCity

我想在 TeamCity 中显示 Spectron 测试结果。我已按照 Webdriverio TeamCity Reporter page 中的说明进行操作,它们是:

npm install wdio-teamcity-reporter --save-dev

并创建一个 wdio.conf.js 文件:

 exports.config = {
  reporters: ['teamcity'],
}

我已将此文件放在项目的顶部。它没有其他条目;我以前从来不需要它。

我也尝试了 wdio-teamcity-reporter npm page.

中建议的附加配置

这是 package.json 中的 Jest 对象:

"jest": {
    "moduleFileExtensions": [
      "ts",
      "tsx",
      "js"
    ],
    "transform": {
      "\.(ts|tsx)$": "<rootDir>/node_modules/ts-jest/preprocessor.js"
    },
    "roots": [
      "<rootDir>/__tests__/",
      "<rootDir>/components/"
    ],
    "modulePaths": [
      "<rootDir>/__tests__/",
      "<rootDir>/components/"
    ],
    "testMatch": [
      "**/?(*.)(spec|test).(ts)?(x)"
    ]
  }

这是 package.json 中的相关命令(TeamCity 调用):

  "scripts": {
    // ...
    "test": "jest --maxWorkers=1 --forceExit",
    // ...
  },

此测试项目是使用 Typescript 和 Jest 构建的,仅包含 Electron 应用程序的 e2e Spectron 测试。该应用程序的构建工件是我的测试 'build' 的 TeamCity 依赖项。在我的构建中,TeamCity 安装应用程序,运行 Spectron 测试(通过),然后卸载应用程序。

目前我只能看到构建日志中的 Jest 控制台输出。虽然有一些隐藏的人工制品,但我看不到正常的人工制品。我在想报告包应该产生一个 html 工件。我该如何着手显示测试选项卡或其他一些有用的结果集?

事实证明,Jest 可以收集所有 Webdriver 结果。尝试使用 https://www.npmjs.com/package/jest-teamcity.

在jest.config.js中使用:

"testResultsProcessor": "jest-teamcity"