teamcityjestjswebdriver-iospectron

Displaying Spectron-Webdriverio test results in TeamCity


I would like to display Spectron test results in TeamCity. I have followed the instructions at the Webdriverio TeamCity Reporter page, which are:

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

and creating a wdio.conf.js file:

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

I have placed this file at the top of the project. It has no other entries; I've never needed it before.

I have also tried the additional configuration suggested at wdio-teamcity-reporter npm page.

This is the Jest object in package.json:

"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)"
    ]
  }

And this is the relevant command (that TeamCity calls) in package.json:

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

This testing project is built with Typescript and Jest, and only comprises the e2e Spectron tests for an Electron app. The build artifact for that app is a TeamCity dependency for my test 'build'. In my build, TeamCity installs the app, runs the Spectron tests (which are passing), and then uninstalls the app.

All I can see at the moment is the Jest console output within the build log. While there are some hidden artifacts, I see no normal artifacts. I was thinking that the reporting package should have produced an html artifact. How do I go about displaying a test tab, or some other useful set of results?


Solution

  • It turns out that Jest can collect all the Webdriver results. Try using https://www.npmjs.com/package/jest-teamcity.

    In jest.config.js use:

    "testResultsProcessor": "jest-teamcity"