Skip to content

Commit

Permalink
[INTERNAL] Karma: Upgrade dependencies / Exclude thirdparty from cove…
Browse files Browse the repository at this point in the history
…rage

karma-coverage to solve regression with karma-coverage v2.0.2:
karma-runner/karma-coverage#418

Use new karma-ui5 option "failOnEmptyTestPage".

Exclude thirdparty code from coverage preprocessing.
We don't want to collect coverage scores from thirdparty code.
Also, with karma-coverage v2.0.2+ there is an issue with instrumenting
sinon-4.js, as it contains a very large inline source map that causes
a heap out of memory error in @babel/core.

Change-Id: I8b74ce6fc6b149d0acc49af2275aa84320346562
  • Loading branch information
matz3 committed Sep 11, 2020
1 parent afc820d commit 9d034f8
Show file tree
Hide file tree
Showing 4 changed files with 404 additions and 406 deletions.
47 changes: 43 additions & 4 deletions lib/test/karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,43 @@ module.exports = function(config) {

};

/*
* Some libraries require individual patterns in order to exclude thirdparty files.
*
* Defining exclude patterns is not straight-forward, see:
* https://github.com/karma-runner/karma/issues/508#issuecomment-45029950
*
* Only single folder names can be excluded, not full paths like sap/ui/thirdparty.
* Also sub-folders are not excluded, so those folder names need to be defined separately.
*
*/
var coveragePatterns = {
/*
* ace (sap/ui/codeeditor/js/ace)
* snippets (sap/ui/codeeditor/js/ace/snippets)
*/
"sap.ui.codeeditor": "{src/*.js,src/**/!(ace|snippets)/*.js}",
/*
* thirdparty (sap/ui/thirdparty)
* hyphenopoly (sap/ui/thirdparty/hyphenopoly)
* jqueryui (sap/ui/thirdparty/jqueryui)
* js (sap/ui/thirdparty/mobiscroll/js)
*/
"sap.ui.core": "{src/*.js,src/**/!(thirdparty|hyphenopoly|jqueryui|mobiscroll|js)/*.js}",
/*
* thirdparty (sap/ui/documentation/sdk/thirdparty)
* google-code-prettify (sap/ui/documentation/sdk/thirdparty/google-code-prettify)
*/
"sap.ui.documentation": "{src/*.js,src/**/!(thirdparty|google-code-prettify)/*.js}",
/*
* thirdparty (sap/ui/integration/thirdparty)
* webcomponents (sap/ui/integration/thirdparty/webcomponents)
* webcomponentsjs (sap/ui/integration/thirdparty/webcomponents/webcomponentsjs)
* bundles (sap/ui/integration/thirdparty/webcomponents/webcomponentsjs/bundles)
*/
"sap.ui.integration": "{src/*.js,src/**/!(thirdparty|webcomponents|webcomponentsjs|bundles)/*.js}"
};

var chromeFlags = [
"--window-size=1280,1024"
];
Expand All @@ -71,7 +108,8 @@ module.exports = function(config) {
key: "hidepassed",
value: true
}
]
],
failOnEmptyTestPage: true
},

customLaunchers: {
Expand Down Expand Up @@ -168,10 +206,11 @@ module.exports = function(config) {

// CLI arg --coverage
if (config.coverage) {
var coveragePattern = coveragePatterns[config.lib] || "src/**/*.js";
var preprocessors = {};
preprocessors[coveragePattern] = ["coverage"];
config.set({
preprocessors: {
"src/**/*.js": ["coverage"]
},
preprocessors: preprocessors,

reporters: config.reporters.concat(["coverage"]),

Expand Down

0 comments on commit 9d034f8

Please sign in to comment.