Skip to content

Commit

Permalink
chore: fix test env
Browse files Browse the repository at this point in the history
  • Loading branch information
WoodNeck committed Nov 9, 2020
1 parent 6289e4f commit b690f95
Show file tree
Hide file tree
Showing 14 changed files with 4,443 additions and 6,695 deletions.
168 changes: 92 additions & 76 deletions karma.conf.js
Original file line number Diff line number Diff line change
@@ -1,91 +1,107 @@
module.exports = config => {
const karmaConfig = {
frameworks: ["mocha", "chai", "sinon"],
const karmaConfig = {
frameworks: ["mocha", "chai", "sinon"],

browserNoActivityTimeout: 60000,
browserNoActivityTimeout: 60000,

// list of files / patterns to load in the browser
files: [
"./node_modules/resemblejs/resemble.js",
"./node_modules/hammer-simulator/index.js",
"./node_modules/webvr-polyfill/build/webvr-polyfill.js",
"./node_modules/webxr-polyfill/build/webxr-polyfill.js",
"./test/hammer-simulator.run.js",
"./test/unit/**/*.spec.js",
{pattern: "./test/manual/img/**/*.*", watched: false, included: false, served: true},
],
// list of files / patterns to load in the browser
files: [
"./node_modules/resemblejs/resemble.js",
"./node_modules/hammer-simulator/index.js",
"./node_modules/webvr-polyfill/build/webvr-polyfill.js",
"./node_modules/webxr-polyfill/build/webxr-polyfill.js",
"./test/hammer-simulator.run.js",
"./test/unit/**/*.spec.js",
{pattern: "./test/manual/img/**/*.*", watched: false, included: false, served: true},
],

proxies: {
"/images/": "/base/test/manual/img/"
},
proxies: {
"/images/": "/base/test/manual/img/"
},

client: {
mocha: {
opts: "./mocha.opts",
timeout: "20000"
}
},
client: {
mocha: {
opts: "./mocha.opts",
timeout: "20000"
}
},

webpack: {
devtool: "inline-source-map",
mode: "none",
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
loader: "babel-loader",
options: {
"babelrc": false,
"presets": [
[
"@babel/preset-env", {
"targets": {"chrome": "55"},
"debug": true
}
]
],
"plugins": [
"@babel/plugin-transform-modules-commonjs",
webpack: {
devtool: "inline-source-map",
resolve: {
extensions: [".ts", ".js"]
},
mode: "none",
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
loader: "babel-loader",
options: {
"babelrc": false,
"presets": [
[
"@babel/preset-env", {
"targets": {"chrome": "55"},
"debug": true
}
]
],
"plugins": [
"@babel/plugin-transform-modules-commonjs",
["@babel/plugin-proposal-class-properties", {"loose": true}],
]
]
}
},
{
test: /\.ts$/,
exclude: /node_modules/,
use: {
loader: "ts-loader",
options: {
transpileOnly: true,
compilerOptions: {
module: "es5",
},
}
}
}
]
}
},
]
}
},

// preprocess matching files before serving them to the browser
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
preprocessors: {
"./test/**/*.spec.js": config.coverage ? ["webpack"] : ["webpack", "sourcemap"]
},
// preprocess matching files before serving them to the browser
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
preprocessors: {
"./test/**/*.spec.js": config.coverage ? ["webpack"] : ["webpack", "sourcemap"]
},

browsers: [],
customLaunchers: {
ChromeHeadlessGL: {
base: "Chrome",
flags: [
"--headless",
"--hide-scrollbars",
"--mute-audio",
"--no-sandbox",
"--disable-setuid-sandbox",
// Without a remote debugging port, Google Chrome exits immediately.
"--remote-debugging-port=9222",
// Although --use-gl=osmesa is not specified. it need to install libosmesa in TRAVIS setting to test sucessfully
]
}
},
reporters: ["mocha"],
webpackMiddleware: {
noInfo: true
}
};
browsers: [],
customLaunchers: {
ChromeHeadlessGL: {
base: "Chrome",
flags: [
"--headless",
"--hide-scrollbars",
"--mute-audio",
"--no-sandbox",
"--disable-setuid-sandbox",
// Without a remote debugging port, Google Chrome exits immediately.
"--remote-debugging-port=9222",
// Although --use-gl=osmesa is not specified. it need to install libosmesa in TRAVIS setting to test sucessfully
]
}
},
reporters: ["mocha"],
webpackMiddleware: {
noInfo: true
}
};

karmaConfig.browsers.push(config.chrome ? "Chrome" : "ChromeHeadlessGL");
karmaConfig.browsers.push(config.chrome ? "Chrome" : "ChromeHeadlessGL");

if (config.coverage) {
if (config.coverage) {
karmaConfig.reporters.push("coverage-istanbul");
karmaConfig.coverageIstanbulReporter = {
reports: ["text-summary", "html", "lcovonly"],
Expand All @@ -99,5 +115,5 @@ module.exports = config => {
karmaConfig.singleRun = true;
}

config.set(karmaConfig);
config.set(karmaConfig);
};
Loading

0 comments on commit b690f95

Please sign in to comment.