Skip to content

Commit

Permalink
[minor] Add chrome headless to component archetype (electrode-io#516)
Browse files Browse the repository at this point in the history
  • Loading branch information
didi0613 authored and jchip committed Aug 6, 2017
1 parent f4955ec commit 7de0490
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 14 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
"use strict";

const archetype = require("electrode-archetype-react-component/config/archetype");
const browser = archetype.karma.browser.toLowerCase();

module.exports = function(settings) {
if (browser === "chrome") {
settings.browsers = ["ChromeHeadless"];
settings.frameworks = ["mocha"];
settings.crossOriginAttribute = false;
console.log("Using Chrome Headless to run Karma test");

} else if (browser === "phantomjs") {
settings.browsers = ["PhantomJS"];
settings.frameworks = ["mocha", "phantomjs-shim"];
console.warn(
"Using PhantomJS to run Karma test. It's been deprecated and may be removed in the future."
);
} else {
console.error(`Unknown browser ${browser} set for Karma test. Failed.`);
return process.exit(1);
}

return settings;
};
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
"use strict";

const browserSettings = require("./browser-settings");

/*
* Karma Configuration: "dev" version.
*
Expand All @@ -9,10 +11,8 @@
* server during the test run.
*/
module.exports = function (config) {
config.set({
frameworks: ["mocha", "phantomjs-shim"],
const base = {
reporters: ["spec"],
browsers: ["PhantomJS"],
basePath: process.cwd(), // repository root.
files: [
// Test bundle (must be created via `npm run dev|hot|server-test`)
Expand All @@ -26,5 +26,9 @@ module.exports = function (config) {
ui: "bdd"
}
}
});
};

browserSettings(base);

config.set(base);
};
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,20 @@ var path = require("path");

var webpackCfg = require("../webpack/webpack.config.test");

var MAIN_PATH = require.resolve("electrode-archetype-react-component-dev/config/karma/entry.js"); // eslint-disable-line max-len
var MAIN_PATH = require.resolve(
"electrode-archetype-react-component-dev/config/karma/entry.js"
);

const browserSettings = require("./browser-settings");

var PREPROCESSORS = {};

PREPROCESSORS[MAIN_PATH] = ["webpack"];

module.exports = function (config) {
config.set({
module.exports = function(config) {
const base = {
basePath: process.cwd(),
frameworks: ["mocha", "phantomjs-shim", "intl-shim"],
files: [
MAIN_PATH
],
files: [MAIN_PATH],
preprocessors: PREPROCESSORS,
webpack: webpackCfg,
webpackServer: {
Expand All @@ -38,7 +39,6 @@ module.exports = function (config) {
logLevel: config.LOG_INFO,
colors: true,
autoWatch: false,
browsers: ["PhantomJS"],
reporters: ["spec", "coverage"],
browserNoActivityTimeout: 60000,
coverageReporter: {
Expand All @@ -51,5 +51,9 @@ module.exports = function (config) {
},
captureTimeout: 100000,
singleRun: true
});
};

browserSettings(base);

config.set(base);
};
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
"json-loader": "^0.5.3",
"jsonfile": "^2.2.2",
"karma": "^1.5.0",
"karma-chrome-launcher": "^0.2.0",
"karma-chrome-launcher": "^2.1.1",
"karma-coverage": "^1.1.1",
"karma-firefox-launcher": "^1",
"karma-ie-launcher": "^1.0.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,8 @@ module.exports = {
devPort: 2992,
testPort: 3001,
modulesDirectories: ["node_modules"]
},
karma: {
browser: process.env.KARMA_BROWSER === undefined ? "chrome" : process.env.KARMA_BROWSER
}
};

0 comments on commit 7de0490

Please sign in to comment.