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
*
* @param {object} config Configuration options to override on/add to the base config.
*/
function createKarmaConfig(config) {
return function (karmaConfig) {
karmaConfig.set({
basePath: path.resolve(__dirname, ".."),
frameworks: ["jasmine"],
files: [
"wwwroot/lib/msgpack5/msgpack5.js",
"node_modules/@aspnet/signalr/dist/browser/signalr.js",
"node_modules/@aspnet/signalr-protocol-msgpack/dist/browser/signalr-protocol-msgpack.js",
"wwwroot/dist/signalr-functional-tests.js"
],
preprocessors: {
"**/*.js": ["sourcemap"]
},
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: false,
singleRun: false,
concurrency: Infinity,
/** Creates the Karma config function based on the provided options
*
* @param {object} config Configuration options to override on/add to the base config.
*/
function createKarmaConfig(config) {
return function (karmaConfig) {
karmaConfig.set({
basePath: path.resolve(__dirname, ".."),
frameworks: ["jasmine"],
files: [
"wwwroot/lib/msgpack5/msgpack5.js",
"node_modules/@aspnet/signalr/dist/browser/signalr.js",
"node_modules/@aspnet/signalr-protocol-msgpack/dist/browser/signalr-protocol-msgpack.js",
"wwwroot/dist/signalr-functional-tests.js"
],
preprocessors: {
"**/*.js": ["sourcemap"]
},
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: false,
singleRun: false,
concurrency: Infinity,
// Log browser messages to a file, not the terminal.
browserConsoleLogOptions: {
level: "debug",
terminal: false
},
// Log browser messages to a file, not the terminal.
browserConsoleLogOptions: {
level: "debug",
terminal: false
},
// Increase some timeouts that are a little aggressive when multiple browsers (or SauceLabs) are in play.
browserDisconnectTimeout: 10000, // default 2000
browserDisconnectTolerance: 1, // default 0
browserNoActivityTimeout: 4 * 60 * 1000, //default 10000
captureTimeout: 4 * 60 * 1000, //default 60000
// Increase some timeouts that are a little aggressive when multiple browsers (or SauceLabs) are in play.
browserDisconnectTimeout: 10000, // default 2000
browserDisconnectTolerance: 1, // default 0
browserNoActivityTimeout: 4 * 60 * 1000, //default 10000
captureTimeout: 4 * 60 * 1000, //default 60000
// Override/add values using the passed-in config.
...config,
// Override/add values using the passed-in config.
...config,
// Apply the default reporters along with whatever was passed in
reporters: [...defaultReporters, ...(config.reporters || [])],
});
// Apply the default reporters along with whatever was passed in
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)
const createKarmaConfig = require("./karma.base.conf");
const fs = require("fs");
const which = require("which");
try {
// Karma configuration for a local run (the default)
const createKarmaConfig = require("./karma.base.conf");
const fs = require("fs");
const which = require("which");
// Bring in the launchers directly to detect browsers
const ChromeHeadlessBrowser = require("karma-chrome-launcher")["launcher:ChromeHeadless"][1];
const ChromiumHeadlessBrowser = require("karma-chrome-launcher")["launcher:ChromiumHeadless"][1];
const FirefoxHeadlessBrowser = require("karma-firefox-launcher")["launcher:FirefoxHeadless"][1];
const EdgeBrowser = require("karma-edge-launcher")["launcher:Edge"][1];
const SafariBrowser = require("karma-safari-launcher")["launcher:Safari"][1];
const IEBrowser = require("karma-ie-launcher")["launcher:IE"][1];
// Bring in the launchers directly to detect browsers
const ChromeHeadlessBrowser = require("karma-chrome-launcher")["launcher:ChromeHeadless"][1];
const ChromiumHeadlessBrowser = require("karma-chrome-launcher")["launcher:ChromiumHeadless"][1];
const FirefoxHeadlessBrowser = require("karma-firefox-launcher")["launcher:FirefoxHeadless"][1];
const EdgeBrowser = require("karma-edge-launcher")["launcher:Edge"][1];
const SafariBrowser = require("karma-safari-launcher")["launcher:Safari"][1];
const IEBrowser = require("karma-ie-launcher")["launcher:IE"][1];
let browsers = [];
let browsers = [];
function browserExists(path) {
// On linux, the browsers just return the command, not a path, so we need to check if it exists.
if (process.platform === "linux") {
return !!which.sync(path, { nothrow: true });
} else {
return fs.existsSync(path);
}
function browserExists(path) {
// On linux, the browsers just return the command, not a path, so we need to check if it exists.
if (process.platform === "linux") {
return !!which.sync(path, { nothrow: true });
} else {
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.
const createKarmaConfig = require("./karma.base.conf");
try {
// Karma configuration for a SauceLabs-based CI run.
const createKarmaConfig = require("./karma.base.conf");
// "Evergreen" Desktop Browsers
var evergreenBrowsers = {
// Microsoft Edge Latest, Windows 10
sl_edge_win10: {
base: "SauceLabs",
browserName: "microsoftedge",
version: "latest",
},
// "Evergreen" Desktop Browsers
var evergreenBrowsers = {
// Microsoft Edge Latest, Windows 10
sl_edge_win10: {
base: "SauceLabs",
browserName: "microsoftedge",
version: "latest",
},
// Apple Safari Latest, macOS 10.13 (High Sierra)
sl_safari_macOS1013: {
base: "SauceLabs",
browserName: "safari",
version: "latest",
platform: "OS X 10.13",
},
// Apple Safari Latest, macOS 10.13 (High Sierra)
sl_safari_macOS1013: {
base: "SauceLabs",
browserName: "safari",
version: "latest",
platform: "OS X 10.13",
},
// Google Chrome Latest, any OS.
sl_chrome: {
base: "SauceLabs",
browserName: "chrome",
version: "latest",
},
// Google Chrome Latest, any OS.
sl_chrome: {
base: "SauceLabs",
browserName: "chrome",
version: "latest",
},
// Mozilla Firefox Latest, any OS
sl_firefox: {
base: "SauceLabs",
browserName: "firefox",
version: "latest",
},
}
// Mozilla Firefox Latest, any OS
sl_firefox: {
base: "SauceLabs",
browserName: "firefox",
version: "latest",
},
}
// Legacy Browsers
var legacyBrowsers = {
// Microsoft Internet Explorer 11, Windows 7
sl_ie11_win7: {
base: "SauceLabs",
browserName: "internet explorer",
version: "11",
platform: "Windows 7",
},
};
// Legacy Browsers
var legacyBrowsers = {
// Microsoft Internet Explorer 11, Windows 7
sl_ie11_win7: {
base: "SauceLabs",
browserName: "internet explorer",
version: "11",
platform: "Windows 7",
},
};
// Mobile Browsers
// TODO: Fill this in.
var mobileBrowsers = {};
// Mobile Browsers
// TODO: Fill this in.
var mobileBrowsers = {};
var customLaunchers = {
...evergreenBrowsers,
...legacyBrowsers,
...mobileBrowsers,
};
var customLaunchers = {
...evergreenBrowsers,
...legacyBrowsers,
...mobileBrowsers,
};
module.exports = createKarmaConfig({
customLaunchers,
browsers: Object.keys(customLaunchers),
reporters: ["saucelabs"],
sauceLabs: {
testName: "SignalR Functional Tests",
connectOptions: {
// Required to enable WebSockets through the Sauce Connect proxy.
noSslBumpDomains: ["all"]
}
},
});
module.exports = createKarmaConfig({
customLaunchers,
browsers: Object.keys(customLaunchers),
reporters: ["saucelabs"],
sauceLabs: {
testName: "SignalR Functional Tests",
connectOptions: {
// Required to enable WebSockets through the Sauce Connect proxy.
noSslBumpDomains: ["all"]
}
},
});
} catch (e) {
console.error(e);
}