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,51 +1,55 @@
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, ".."),
frameworks: ["jasmine"], frameworks: ["jasmine"],
files: [ files: [
"wwwroot/lib/msgpack5/msgpack5.js", "wwwroot/lib/msgpack5/msgpack5.js",
"node_modules/@aspnet/signalr/dist/browser/signalr.js", "node_modules/@aspnet/signalr/dist/browser/signalr.js",
"node_modules/@aspnet/signalr-protocol-msgpack/dist/browser/signalr-protocol-msgpack.js", "node_modules/@aspnet/signalr-protocol-msgpack/dist/browser/signalr-protocol-msgpack.js",
"wwwroot/dist/signalr-functional-tests.js" "wwwroot/dist/signalr-functional-tests.js"
], ],
preprocessors: { preprocessors: {
"**/*.js": ["sourcemap"] "**/*.js": ["sourcemap"]
}, },
port: 9876, port: 9876,
colors: true, colors: true,
logLevel: config.LOG_INFO, logLevel: config.LOG_INFO,
autoWatch: false, autoWatch: false,
singleRun: false, singleRun: false,
concurrency: Infinity, concurrency: Infinity,
// Log browser messages to a file, not the terminal. // Log browser messages to a file, not the terminal.
browserConsoleLogOptions: { browserConsoleLogOptions: {
level: "debug", level: "debug",
terminal: false terminal: false
}, },
// Increase some timeouts that are a little aggressive when multiple browsers (or SauceLabs) are in play. // Increase some timeouts that are a little aggressive when multiple browsers (or SauceLabs) are in play.
browserDisconnectTimeout: 10000, // default 2000 browserDisconnectTimeout: 10000, // default 2000
browserDisconnectTolerance: 1, // default 0 browserDisconnectTolerance: 1, // default 0
browserNoActivityTimeout: 4 * 60 * 1000, //default 10000 browserNoActivityTimeout: 4 * 60 * 1000, //default 10000
captureTimeout: 4 * 60 * 1000, //default 60000 captureTimeout: 4 * 60 * 1000, //default 60000
// Override/add values using the passed-in config. // Override/add values using the passed-in config.
...config, ...config,
// Apply the default reporters along with whatever was passed in // Apply the default reporters along with whatever was passed in
reporters: [...defaultReporters, ...(config.reporters || [])], reporters: [...defaultReporters, ...(config.reporters || [])],
}); });
}
} }
}
module.exports = createKarmaConfig; module.exports = createKarmaConfig;
} catch (e) {
console.error(e);
}

View File

@ -1,55 +1,59 @@
// 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) {
var path = b.DEFAULT_CMD[process.platform];
if (b.ENV_CMD && process.env[b.ENV_CMD]) {
path = process.env[b.ENV_CMD];
}
console.log(`Checking for ${name} at ${path}...`);
if (path && browserExists(path)) {
console.log(`Located ${name} at ${path}.`);
browsers.push(name);
}
else {
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.
tryAddBrowser("ChromeHeadless", new ChromeHeadlessBrowser(() => { }, {}));
tryAddBrowser("ChromiumHeadless", new ChromiumHeadlessBrowser(() => { }, {}));
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.
if (process.env.ASPNETCORE_SIGNALR_TEST_ALL_BROWSERS === "true") {
tryAddBrowser("Edge", new EdgeBrowser(() => { }, { create() { } }));
tryAddBrowser("IE", new IEBrowser(() => { }, { create() { } }, {}));
tryAddBrowser("Safari", new SafariBrowser(() => { }, {}));
}
module.exports = createKarmaConfig({
browsers,
});
} catch (e) {
console.error(e);
} }
function tryAddBrowser(name, b) {
var path = b.DEFAULT_CMD[process.platform];
if (b.ENV_CMD && process.env[b.ENV_CMD]) {
path = process.env[b.ENV_CMD];
}
console.log(`Checking for ${name} at ${path}...`);
if (path && browserExists(path)) {
console.log(`Located ${name} at ${path}.`);
browsers.push(name);
}
else {
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.
tryAddBrowser("ChromeHeadless", new ChromeHeadlessBrowser(() => { }, {}));
tryAddBrowser("ChromiumHeadless", new ChromiumHeadlessBrowser(() => { }, {}));
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.
if (process.env.ASPNETCORE_SIGNALR_TEST_ALL_BROWSERS === "true") {
tryAddBrowser("Edge", new EdgeBrowser(() => { }, { create() { } }));
tryAddBrowser("IE", new IEBrowser(() => { }, { create() { } }, {}));
tryAddBrowser("Safari", new SafariBrowser(() => { }, {}));
}
module.exports = createKarmaConfig({
browsers,
});

View File

@ -1,68 +1,72 @@
// 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",
browserName: "microsoftedge", browserName: "microsoftedge",
version: "latest", version: "latest",
}, },
// Apple Safari Latest, macOS 10.13 (High Sierra) // Apple Safari Latest, macOS 10.13 (High Sierra)
sl_safari_macOS1013: { sl_safari_macOS1013: {
base: "SauceLabs", base: "SauceLabs",
browserName: "safari", browserName: "safari",
version: "latest", version: "latest",
platform: "OS X 10.13", platform: "OS X 10.13",
}, },
// Google Chrome Latest, any OS. // Google Chrome Latest, any OS.
sl_chrome: { sl_chrome: {
base: "SauceLabs", base: "SauceLabs",
browserName: "chrome", browserName: "chrome",
version: "latest", version: "latest",
}, },
// Mozilla Firefox Latest, any OS // Mozilla Firefox Latest, any OS
sl_firefox: { sl_firefox: {
base: "SauceLabs", base: "SauceLabs",
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",
browserName: "internet explorer", browserName: "internet explorer",
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"],
sauceLabs: { sauceLabs: {
testName: "SignalR Functional Tests", testName: "SignalR Functional Tests",
connectOptions: { connectOptions: {
// Required to enable WebSockets through the Sauce Connect proxy. // Required to enable WebSockets through the Sauce Connect proxy.
noSslBumpDomains: ["all"] noSslBumpDomains: ["all"]
} }
}, },
}); });
} catch (e) {
console.error(e);
}