即使未满足测试覆盖率阈值,业力覆盖退出代码始终为 0
Karma-coverage exit code is always 0 even when test coverage threshold is not met
我正在尝试为 UI5 应用程序构建一个 gitlab-ci 管道,以包括使用 Karma runner 和 karma-ui5 的测试阶段。如果未满足测试覆盖率阈值,我希望管道失败。我的 karma.conf.js 看起来像这样:
module.exports = function(config) {
"use strict";
config.set({
frameworks: ["ui5"],
preprocessors: {
"{webapp,webapp/!(test)}/*.js": ["coverage"]
},
coverageReporter: {
includeAllSources: true,
reporters: [
{
type: "html",
dir: "coverage"
},
{
type: "text"
}
],
check: {
each: {
statements: 100,
branches: 100,
functions: 100,
lines: 100
}
}
},
reporters: ["progress", "coverage"],
browsers: ["CustomChromeHeadless"],
customLaunchers: {
CustomChromeHeadless: {
base: 'ChromeHeadless',
flags: ['--no-sandbox']
}
},
browserConsoleLogOptions: {
level: "error"
},
singleRun: true
});
};
Karma 覆盖报告不满足覆盖阈值的文件,但退出代码始终为 0,因此管道不会失败。
输出如下所示:
TOTAL: 2 SUCCESS
07 11 2020 10:08:46.033:ERROR [coverage]: HeadlessChrome 64.0.3282 (Linux 0.0.0): Coverage for branches (50%) does not meet per-file (/builds/younang/ci/web/webapp/controller/View.controller.js) threshold (100%)
07 11 2020 10:08:46.034:ERROR [coverage]: HeadlessChrome 64.0.3282 (Linux 0.0.0): Coverage for statements (0%) does not meet per-file (/builds/younang/ci/web/webapp/localService/mockserver.js) threshold (100%)
07 11 2020 10:08:46.034:ERROR [coverage]: HeadlessChrome 64.0.3282 (Linux 0.0.0): Coverage for branches (0%) does not meet per-file (/builds/younang/ci/web/webapp/localService/mockserver.js) threshold (100%)
07 11 2020 10:08:46.034:ERROR [coverage]: HeadlessChrome 64.0.3282 (Linux 0.0.0): Coverage for lines (0%) does not meet per-file (/builds/younang/ci/web/webapp/localService/mockserver.js) threshold (100%)
07 11 2020 10:08:46.034:ERROR [coverage]: HeadlessChrome 64.0.3282 (Linux 0.0.0): Coverage for functions (0%) does not meet per-file (/builds/younang/ci/web/webapp/localService/mockserver.js) threshold (100%)
-------------------|---------|----------|---------|---------|-------------------
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
-------------------|---------|----------|---------|---------|-------------------
All files | 25 | 4.35 | 41.18 | 25 |
webapp | 100 | 100 | 100 | 100 |
Component.js | 100 | 100 | 100 | 100 |
webapp/controller | 100 | 50 | 100 | 100 |
...controller.js | 100 | 50 | 100 | 100 | 16
...p/localService | 0 | 0 | 0 | 0 |
mockserver.js | 0 | 0 | 0 | 0 | 1-115
webapp/model | 100 | 100 | 100 | 100 |
models.js | 100 | 100 | 100 | 100 |
-------------------|---------|----------|---------|---------|------------------
您可以在 Gitlab here
中查看完整设置
知道我在这里错过了什么吗?非常感谢ci帮助。
谢谢
看起来这是 known issue。解决方案是将 karma 升级到 5.2.0
。也许试一试?
我正在尝试为 UI5 应用程序构建一个 gitlab-ci 管道,以包括使用 Karma runner 和 karma-ui5 的测试阶段。如果未满足测试覆盖率阈值,我希望管道失败。我的 karma.conf.js 看起来像这样:
module.exports = function(config) {
"use strict";
config.set({
frameworks: ["ui5"],
preprocessors: {
"{webapp,webapp/!(test)}/*.js": ["coverage"]
},
coverageReporter: {
includeAllSources: true,
reporters: [
{
type: "html",
dir: "coverage"
},
{
type: "text"
}
],
check: {
each: {
statements: 100,
branches: 100,
functions: 100,
lines: 100
}
}
},
reporters: ["progress", "coverage"],
browsers: ["CustomChromeHeadless"],
customLaunchers: {
CustomChromeHeadless: {
base: 'ChromeHeadless',
flags: ['--no-sandbox']
}
},
browserConsoleLogOptions: {
level: "error"
},
singleRun: true
});
};
Karma 覆盖报告不满足覆盖阈值的文件,但退出代码始终为 0,因此管道不会失败。
输出如下所示:
TOTAL: 2 SUCCESS
07 11 2020 10:08:46.033:ERROR [coverage]: HeadlessChrome 64.0.3282 (Linux 0.0.0): Coverage for branches (50%) does not meet per-file (/builds/younang/ci/web/webapp/controller/View.controller.js) threshold (100%)
07 11 2020 10:08:46.034:ERROR [coverage]: HeadlessChrome 64.0.3282 (Linux 0.0.0): Coverage for statements (0%) does not meet per-file (/builds/younang/ci/web/webapp/localService/mockserver.js) threshold (100%)
07 11 2020 10:08:46.034:ERROR [coverage]: HeadlessChrome 64.0.3282 (Linux 0.0.0): Coverage for branches (0%) does not meet per-file (/builds/younang/ci/web/webapp/localService/mockserver.js) threshold (100%)
07 11 2020 10:08:46.034:ERROR [coverage]: HeadlessChrome 64.0.3282 (Linux 0.0.0): Coverage for lines (0%) does not meet per-file (/builds/younang/ci/web/webapp/localService/mockserver.js) threshold (100%)
07 11 2020 10:08:46.034:ERROR [coverage]: HeadlessChrome 64.0.3282 (Linux 0.0.0): Coverage for functions (0%) does not meet per-file (/builds/younang/ci/web/webapp/localService/mockserver.js) threshold (100%)
-------------------|---------|----------|---------|---------|-------------------
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
-------------------|---------|----------|---------|---------|-------------------
All files | 25 | 4.35 | 41.18 | 25 |
webapp | 100 | 100 | 100 | 100 |
Component.js | 100 | 100 | 100 | 100 |
webapp/controller | 100 | 50 | 100 | 100 |
...controller.js | 100 | 50 | 100 | 100 | 16
...p/localService | 0 | 0 | 0 | 0 |
mockserver.js | 0 | 0 | 0 | 0 | 1-115
webapp/model | 100 | 100 | 100 | 100 |
models.js | 100 | 100 | 100 | 100 |
-------------------|---------|----------|---------|---------|------------------
您可以在 Gitlab here
中查看完整设置知道我在这里错过了什么吗?非常感谢ci帮助。
谢谢
看起来这是 known issue。解决方案是将 karma 升级到 5.2.0
。也许试一试?