Sauce Labs 徽章显示未知 karma.js

Sauce Labs badge showing unknown karma.js

在项目的 README.md 文件中包含 Status Badge 时使用:

[![Sauce Test Status](https://saucelabs.com/buildstatus/YOUR_SAUCE_USERNAME)](https://saucelabs.com/u/YOUR_SAUCE_USERNAME)

正在显示:

而不是这个:

package.json 文件中的相关 devDependencies

"karma": "^1.7.0",
"karma-chrome-launcher": "^2.1.1",
"karma-jasmine": "^1.1.0",
"karma-sauce-launcher": "^1.1.0",

karma.conf.js 文件中的相关配置设置:

singleRun: process.env.CI,
sauceLabs: {
  testName: 'Web App Tests'
},
customLaunchers: customLaunchers,
reporters: process.env.CI ? ['dots', 'saucelabs'] : ['progress']

我通过构建版本添加karma.conf.js文件来解决这个问题:


    singleRun: process.env.CI,
    sauceLabs: {
      build: require('./package.json').version, // New
      testName: 'Web App Tests'
    },
    customLaunchers: customLaunchers,
    reporters: process.env.CI ? ['dots', 'saucelabs'] : ['progress']