Skip to content

Commit

Permalink
build(karma): add browser testing capability
Browse files Browse the repository at this point in the history
Signed-off-by: suyukuoacn <su-yu.kuo@accenture.com>
  • Loading branch information
suyukuoacn authored and petermetz committed Aug 18, 2020
1 parent 4563874 commit a51684c
Show file tree
Hide file tree
Showing 7 changed files with 2,199 additions and 75 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ docs/main
logs/
jspm_packages/
generated-sources/
coverage/

# Optional npm cache directory
.npm
Expand Down
100 changes: 100 additions & 0 deletions karma.conf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
module.exports = (config) => {
config.set({
singleRun: true,
logLevel: config.LOG_INFO,
colors: true,

frameworks: ["tap"],

// Use "Chrome" if you need to debug tests with the actual browser window
// being open and you want to use Chrome Dev Tools for it.
browsers: [
// 'Electron',
// "ElectronWithGui",
// 'Chrome',
// 'ChromeHeadless',
"ChromeHeadlessDebug",
],

files: [
{
pattern: "packages/cactus-common/src/test/typescript/unit/**/*.ts",
},
],

plugins: [
"karma-chrome-launcher",
"karma-electron",
"karma-tap",
"karma-webpack",
],

preprocessors: {
"**/*.ts": ["webpack"],
},

browserConsoleLogOptions: {
level: "debug",
format: "%b %T: %m",
terminal: true,
},

reporters: ["dots"],

webpack: {
mode: "development",
devtool: "inline-source-map",
module: {
rules: [
{
test: /\.ts$/,
exclude: /node_modules/,
use: [
{
loader: "ts-loader",
},
],
},
],
},
resolve: {
extensions: [".ts", ".js"],
},
node: {
fs: "empty",
},
},

webpackMiddleware: {
// without this the webpack compilation log is shown as well
stats: "errors-only",
},

customLaunchers: {
ElectronWithGui: {
base: "Electron",
flags: [
"--show",
"--disable-translate",
"--disable-extensions",
"--no-first-run",
"--disable-background-networking",
"--remote-debugging-port=9222",
"--remote-debugging-address=127.0.0.1",
],
},

ChromeHeadlessDebug: {
base: "ChromeHeadless",
flags: [
"--disable-translate",
"--disable-extensions",
"--no-first-run",
"--disable-background-networking",
"--remote-debugging-port=9222",
"--remote-debugging-address=127.0.0.1",
],
},
},
});
};
Loading

0 comments on commit a51684c

Please sign in to comment.