Show errors from Karma (#2545)

This commit is contained in:
BrennanConroy 2018-06-26 20:47:07 -07:00 committed by GitHub
parent 93cfdeb572
commit bc8aae5d50
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 166 additions and 154 deletions

View File

@ -1,12 +1,13 @@
const path = require("path"); try {
const path = require("path");
let defaultReporters = ["progress", "summary"]; let defaultReporters = ["progress", "summary"];
/** Creates the Karma config function based on the provided options /** Creates the Karma config function based on the provided options
* *
* @param {object} config Configuration options to override on/add to the base config. * @param {object} config Configuration options to override on/add to the base config.
*/ */
function createKarmaConfig(config) { function createKarmaConfig(config) {
return function (karmaConfig) { return function (karmaConfig) {
karmaConfig.set({ karmaConfig.set({
basePath: path.resolve(__dirname, ".."), basePath: path.resolve(__dirname, ".."),
@ -46,6 +47,9 @@ function createKarmaConfig(config) {
reporters: [...defaultReporters, ...(config.reporters || [])], reporters: [...defaultReporters, ...(config.reporters || [])],
}); });
} }
} }
module.exports = createKarmaConfig; module.exports = createKarmaConfig;
} catch (e) {
console.error(e);
}

View File

@ -1,28 +1,29 @@
// Karma configuration for a local run (the default) try {
const createKarmaConfig = require("./karma.base.conf"); // Karma configuration for a local run (the default)
const fs = require("fs"); const createKarmaConfig = require("./karma.base.conf");
const which = require("which"); const fs = require("fs");
const which = require("which");
// Bring in the launchers directly to detect browsers // Bring in the launchers directly to detect browsers
const ChromeHeadlessBrowser = require("karma-chrome-launcher")["launcher:ChromeHeadless"][1]; const ChromeHeadlessBrowser = require("karma-chrome-launcher")["launcher:ChromeHeadless"][1];
const ChromiumHeadlessBrowser = require("karma-chrome-launcher")["launcher:ChromiumHeadless"][1]; const ChromiumHeadlessBrowser = require("karma-chrome-launcher")["launcher:ChromiumHeadless"][1];
const FirefoxHeadlessBrowser = require("karma-firefox-launcher")["launcher:FirefoxHeadless"][1]; const FirefoxHeadlessBrowser = require("karma-firefox-launcher")["launcher:FirefoxHeadless"][1];
const EdgeBrowser = require("karma-edge-launcher")["launcher:Edge"][1]; const EdgeBrowser = require("karma-edge-launcher")["launcher:Edge"][1];
const SafariBrowser = require("karma-safari-launcher")["launcher:Safari"][1]; const SafariBrowser = require("karma-safari-launcher")["launcher:Safari"][1];
const IEBrowser = require("karma-ie-launcher")["launcher:IE"][1]; const IEBrowser = require("karma-ie-launcher")["launcher:IE"][1];
let browsers = []; let browsers = [];
function browserExists(path) { function browserExists(path) {
// On linux, the browsers just return the command, not a path, so we need to check if it exists. // On linux, the browsers just return the command, not a path, so we need to check if it exists.
if (process.platform === "linux") { if (process.platform === "linux") {
return !!which.sync(path, { nothrow: true }); return !!which.sync(path, { nothrow: true });
} else { } else {
return fs.existsSync(path); return fs.existsSync(path);
} }
} }
function tryAddBrowser(name, b) { function tryAddBrowser(name, b) {
var path = b.DEFAULT_CMD[process.platform]; var path = b.DEFAULT_CMD[process.platform];
if (b.ENV_CMD && process.env[b.ENV_CMD]) { if (b.ENV_CMD && process.env[b.ENV_CMD]) {
path = process.env[b.ENV_CMD]; path = process.env[b.ENV_CMD];
@ -36,20 +37,23 @@ function tryAddBrowser(name, b) {
else { else {
console.log(`Unable to locate ${name}. Skipping.`); console.log(`Unable to locate ${name}. Skipping.`);
} }
} }
// We use the launchers themselves to figure out if the browser exists. It's a bit sneaky, but it works. // We use the launchers themselves to figure out if the browser exists. It's a bit sneaky, but it works.
tryAddBrowser("ChromeHeadless", new ChromeHeadlessBrowser(() => { }, {})); tryAddBrowser("ChromeHeadless", new ChromeHeadlessBrowser(() => { }, {}));
tryAddBrowser("ChromiumHeadless", new ChromiumHeadlessBrowser(() => { }, {})); tryAddBrowser("ChromiumHeadless", new ChromiumHeadlessBrowser(() => { }, {}));
tryAddBrowser("FirefoxHeadless", new FirefoxHeadlessBrowser(0, () => { }, {})); tryAddBrowser("FirefoxHeadless", new FirefoxHeadlessBrowser(0, () => { }, {}));
// We need to receive an argument from the caller, but globals don't seem to work, so we use an environment variable. // We need to receive an argument from the caller, but globals don't seem to work, so we use an environment variable.
if (process.env.ASPNETCORE_SIGNALR_TEST_ALL_BROWSERS === "true") { if (process.env.ASPNETCORE_SIGNALR_TEST_ALL_BROWSERS === "true") {
tryAddBrowser("Edge", new EdgeBrowser(() => { }, { create() { } })); tryAddBrowser("Edge", new EdgeBrowser(() => { }, { create() { } }));
tryAddBrowser("IE", new IEBrowser(() => { }, { create() { } }, {})); tryAddBrowser("IE", new IEBrowser(() => { }, { create() { } }, {}));
tryAddBrowser("Safari", new SafariBrowser(() => { }, {})); tryAddBrowser("Safari", new SafariBrowser(() => { }, {}));
} }
module.exports = createKarmaConfig({ module.exports = createKarmaConfig({
browsers, browsers,
}); });
} catch (e) {
console.error(e);
}

View File

@ -1,8 +1,9 @@
// Karma configuration for a SauceLabs-based CI run. try {
const createKarmaConfig = require("./karma.base.conf"); // Karma configuration for a SauceLabs-based CI run.
const createKarmaConfig = require("./karma.base.conf");
// "Evergreen" Desktop Browsers // "Evergreen" Desktop Browsers
var evergreenBrowsers = { var evergreenBrowsers = {
// Microsoft Edge Latest, Windows 10 // Microsoft Edge Latest, Windows 10
sl_edge_win10: { sl_edge_win10: {
base: "SauceLabs", base: "SauceLabs",
@ -31,10 +32,10 @@ var evergreenBrowsers = {
browserName: "firefox", browserName: "firefox",
version: "latest", version: "latest",
}, },
} }
// Legacy Browsers // Legacy Browsers
var legacyBrowsers = { var legacyBrowsers = {
// Microsoft Internet Explorer 11, Windows 7 // Microsoft Internet Explorer 11, Windows 7
sl_ie11_win7: { sl_ie11_win7: {
base: "SauceLabs", base: "SauceLabs",
@ -42,19 +43,19 @@ var legacyBrowsers = {
version: "11", version: "11",
platform: "Windows 7", platform: "Windows 7",
}, },
}; };
// Mobile Browsers // Mobile Browsers
// TODO: Fill this in. // TODO: Fill this in.
var mobileBrowsers = {}; var mobileBrowsers = {};
var customLaunchers = { var customLaunchers = {
...evergreenBrowsers, ...evergreenBrowsers,
...legacyBrowsers, ...legacyBrowsers,
...mobileBrowsers, ...mobileBrowsers,
}; };
module.exports = createKarmaConfig({ module.exports = createKarmaConfig({
customLaunchers, customLaunchers,
browsers: Object.keys(customLaunchers), browsers: Object.keys(customLaunchers),
reporters: ["saucelabs"], reporters: ["saucelabs"],
@ -65,4 +66,7 @@ module.exports = createKarmaConfig({
noSslBumpDomains: ["all"] noSslBumpDomains: ["all"]
} }
}, },
}); });
} catch (e) {
console.error(e);
}