Skip to content

Commit

Permalink
feat(karma-ui5-transpile): Apply instrumenterOptions for Istanbul f…
Browse files Browse the repository at this point in the history
…rom `coverageReporter` in `karma.config` (#788)

* feat: apply istanbul config from coverageReporter in karma.config

Signed-off-by: D056969 <[email protected]>

* fix(typo): fix spelling of the variable name

Signed-off-by: D056969 <[email protected]>

* fix(karma-ui5-transpile): apply review feedback

avoid useless check, reuse created variable

Signed-off-by: D056969 <[email protected]>

---------

Signed-off-by: D056969 <[email protected]>
  • Loading branch information
MuwuM authored Aug 9, 2023
1 parent ba5d734 commit 574d5dd
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions packages/karma-ui5-transpile/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ const yaml = require("js-yaml");
*
* Kudos goes to: https://github.com/babel/karma-babel-preprocessor
* which inspired the creation of this Karma preprocessor.
*
* @param {object} config Config object of UI5.
* @param {object} logger Karma's logger.
* @returns {Function} The preprocess function.
Expand Down Expand Up @@ -75,21 +74,23 @@ function createPreprocessor(config, logger) {
return plugin.file.request === "istanbul";
})
) {
const istanbulConfig = {
include: ["**/*"],
exclude: []
};
// apply the `instrumenterOptions` for istanbul from `coverageReporter` in the `karma.config`
const instrumenterOptionsIstanbul = config.coverageReporter?.instrumenterOptions?.istanbul;
if (typeof instrumenterOptionsIstanbul === "object") {
Object.assign(istanbulConfig, instrumenterOptionsIstanbul);
}
// add istanbul as first plugin into the plugins chain
babelOptions.plugins.unshift([
"istanbul",
{
include: ["**/*"],
exclude: []
}
]);
babelOptions.plugins.unshift(["istanbul", istanbulConfig]);
}
return babelOptions;
});

/**
* preprocess function for the individual files to transpile
*
* @param {string} content file content
* @param {object} file file info
* @param {Function} done callback function when done
Expand Down

0 comments on commit 574d5dd

Please sign in to comment.