Skip to content

Commit

Permalink
Fix karma.conf
Browse files Browse the repository at this point in the history
Signed-off-by: davimarinho <[email protected]>
  • Loading branch information
DaviMarinho committed Nov 6, 2023
1 parent 74956b8 commit 55c6c1b
Showing 1 changed file with 69 additions and 14 deletions.
83 changes: 69 additions & 14 deletions karma.conf.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,71 @@
module.exports = function(config) {
config.set({
basePath: '../..',
frameworks: ['jasmine'],
browsers: [
'Chrome',
'ChromeHeadlessCI'
module.exports = (config) => {
const coverage = config.singleRun ? ["coverage"] : [];

config.set({
frameworks: ["jasmine"],
plugins: [
"karma-jasmine",
"karma-webpack",
"karma-coverage",
"karma-remap-istanbul",
"karma-chrome-launcher",
],
customLaunchers: {
ChromeHeadlessCI: {
base: 'ChromeHeadless',
flags: ['--no-sandbox']
}
files: [
"./src/tests.entry.ts",
{
pattern: "**/*.map",
served: true,
included: false,
watched: true,
},
],
preprocessors: {
"./src/tests.entry.ts": ["webpack", "sourcemap"],
"./src/**/!(*.test|tests.*).(ts|js)": ["sourcemap"],
},

webpack: {
plugins,
entry: "./src/tests.entry.ts",
devtool: "inline-source-map",
resolve: {
extensions: [".webpack.js", ".web.js", ".ts", ".js"],
},
module: {
rules: combinedLoaders().concat(
config.singleRun ? [loaders.istanbulInstrumenter] : []
),
},
stats: { colors: true, reasons: true },
},
webpackServer: {
noInfo: true, // prevent console spamming when running in Karma!
},

reporters: ["spec"]
.concat(coverage)
.concat(coverage.length > 0 ? ["karma-remap-istanbul"] : []),

remapIstanbulReporter: {
src: "coverage/chrome/coverage-final.json",
reports: {
html: "coverage",
},
},

coverageReporter: {
reporters: [{ type: "json" }],
dir: "./coverage/",
subdir: (browser) => {
return browser.toLowerCase().split(/[ /-]/)[0]; // returns 'chrome'
},
},
})
};

port: 9876,
browsers: ["Chrome"], // Alternatively: 'PhantomJS'
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
captureTimeout: 6000,
});
};

0 comments on commit 55c6c1b

Please sign in to comment.