Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.

BREAKING: Removed support for Saucelabs #5

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 3 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -185,9 +185,9 @@ module.exports = require("@jsdevtools/karma-config")({
|`browsers` |`object` | |This object allows you to specify which browsers to test on
|`browsers.chrome` |`boolean` |`true` for Linux<br>`false` on other platforms |Whether to test on Chrome.
|`browsers.firefox`|`boolean` |`true` for Linux<br>`false` on other platforms |Whether to test on Firefox.
|`browsers.safari` |`boolean` |`true` for Mac<br>`false` on other platforms |Whether to test on Safari.<br>Can use [SauceLabs](#saucelabs) if configured.
|`browsers.edge` |`boolean` |`true` for Windows<br>`false` on other platforms |Whether to test on Edge (the EdgeHTML engine, not Chromium).<br>Can use [SauceLabs](#saucelabs) if configured.
|`browsers.ie` |`boolean` |`false` |Whether to test on Internet Explorer.<br>Can use [SauceLabs](#saucelabs) if configured.
|`browsers.safari` |`boolean` |`true` for Mac<br>`false` on other platforms |Whether to test on Safari.
|`browsers.edge` |`boolean` |`true` for Windows<br>`false` on other platforms |Whether to test on Edge (the EdgeHTML engine, not Chromium).
|`browsers.ie` |`boolean` |`false` |Whether to test on Internet Explorer.
|`sourceDir` |`string` |`src` |The relative path of the source directory.
|`testDir` |`string` |`test` |The relative path of the test directory.
|`tests` |`string` `string[]` `object` `object[]`|`${testDir}/**/*.spec.js` `${testDir}/**/*.test.js` `${testDir}/**/*.spec.jsx` `${testDir}/**/*.test.jsx` `${testDir}/**/*.spec.mjs` `${testDir}/**/*.test.mjs`|One or more [file patterns](https://karma-runner.github.io/3.0/config/files.html) that specify your test files. These are the files that will be bundled by Webpack and run by Karma.
Expand All @@ -200,30 +200,6 @@ module.exports = require("@jsdevtools/karma-config")({
|`config` |`object` |`{}` |Explicit Karma configuration settings. This is useful for adding additional settings that aren't normally set by Karma Config, or for overriding Karma Config's settings.



SauceLabs
--------------------------
Safari, Edge, and Internet Explorer aren't supported on some CI/CD services. Karma Config allows you to use [SauceLabs](https://saucelabs.com) to test on these browsers.

Karma Config uses the [Sauce Connect proxy](https://wiki.saucelabs.com/display/DOCS/Sauce+Connect+Proxy) to open a secure channel to SauceLabs. Sauce Connect is **only supported on Linux** and requires the `SAUCE_USERNAME` and `SAUCE_ACCESS_KEY` environment variables to be set.

```javascript
module.exports = require("@jsdevtools/karma-config")({
browsers: {
// No need to explicitly set these, since they are tested by default on Linux
// firefox: true,
// chrome: true,

// Test these browsers using SauceLabs
ie: true,
edge: true,
safari: true,
}
});
```



Contributing
--------------------------
Contributions, enhancements, and bug-fixes are welcome! [Open an issue](https://github.com/JS-DevTools/karma-config/issues) on GitHub and [submit a pull request](https://github.com/JS-DevTools/karma-config/pulls).
Expand Down Expand Up @@ -260,5 +236,3 @@ Thanks to these awesome companies for their support of Open Source developers
[![GitHub](https://jstools.dev/img/badges/github.svg)](https://github.com/open-source)
[![NPM](https://jstools.dev/img/badges/npm.svg)](https://www.npmjs.com/)
[![Coveralls](https://jstools.dev/img/badges/coveralls.svg)](https://coveralls.io)
[![Travis CI](https://jstools.dev/img/badges/travis-ci.svg)](https://travis-ci.com)
[![SauceLabs](https://jstools.dev/img/badges/sauce-labs.svg)](https://saucelabs.com)
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@
"karma-ie-launcher": "^1.0.0",
"karma-mocha": "^2.0.1",
"karma-safari-launcher": "^1.0.0",
"karma-sauce-launcher": "^4.3.6",
"karma-verbose-reporter": "^0.0.8",
"karma-webpack": "^4.0.2",
"webpack": "^4.43.0"
Expand Down
106 changes: 3 additions & 103 deletions src/configure-browsers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,109 +31,9 @@ export function configureBrowsers(config: ConfigOptions, options: NormalizedOpti
firefox && browsers.push("Firefox");
}

if (canRunSauceConnect(options)) {
configureSauceLabs(config, options);
}
else {
safari && browsers.push("Safari");
edge && browsers.push("Edge");
ie && browsers.push("IE");
}

return config;
}

/**
* Determines whether the system meets the requirements for running the Sauce Connect proxy.
*
* @see https://github.com/karma-runner/karma-sauce-launcher
*/
function canRunSauceConnect(options: NormalizedOptions): boolean {
let username = process.env.SAUCE_USERNAME;
let accessKey = process.env.SAUCE_ACCESS_KEY;

return Boolean(options.linux && username && accessKey);
}

/**
* Configures Karma to use Sauce Labs for Windows browser testing.
* Returns `false` if Sauce Labs credentials are not present.
*
* @see https://github.com/karma-runner/karma-sauce-launcher
*/
function configureSauceLabs(config: ConfigOptions, options: NormalizedOptions): ConfigOptions {
let { browsers: { safari, edge, ie }} = options;
let browsers = config.browsers!;

if (!(safari || edge || ie)) {
// No need to run tests on Sauce Labs
return config;
}

addPlugin(config, "karma-sauce-launcher");

let buildNumber =
process.env.BUILD_NUMBER ||
process.env.BUILD_TAG ||
process.env.CI_BUILD_NUMBER ||
process.env.CI_BUILD_TAG ||
process.env.TRAVIS_BUILD_NUMBER ||
process.env.CIRCLE_BUILD_NUM ||
process.env.DRONE_BUILD_NUMBER ||
process.env.GITHUB_RUN_NUMBER ||
Date.now();

let pkg = readPackageJson();

config.reporters!.push("saucelabs");

config = mergeConfig(config, {
logLevel: "debug",
// concurrency: 1,
captureTimeout: 60000,
browserDisconnectTolerance: 5,
browserDisconnectTimeout: 60000,
browserNoActivityTimeout: 60000,
});

config.sauceLabs = mergeConfig(config.sauceLabs, {
build: `${pkg.name} v${pkg.version} Build #${buildNumber}`,
testName: `${pkg.name} v${pkg.version}`,
tags: [pkg.name],
});

config.customLaunchers = config.customLaunchers || {};

if (safari) {
browsers.push("Safari_SauceLabs");
// eslint-disable-next-line camelcase
config.customLaunchers.Safari_SauceLabs = mergeConfig(config.customLaunchers.Safari_SauceLabs, {
base: "SauceLabs",
platform: "MacOS 10.15", // Catalina
browserName: "safari",
});
}

if (edge) {
browsers.push("Edge_SauceLabs");
// eslint-disable-next-line camelcase
config.customLaunchers.Edge_SauceLabs = mergeConfig(config.customLaunchers.Edge_SauceLabs, {
base: "SauceLabs",
platform: "Windows 10",
browserName: "microsoftedge",
version: "18.17763", // The last version of EdgeHTML, before the switch to Chromium
});
}

if (ie) {
browsers.push("IE_SauceLabs");
// eslint-disable-next-line camelcase
config.customLaunchers.IE_SauceLabs = mergeConfig(config.customLaunchers.IE_SauceLabs, {
base: "SauceLabs",
platform: "Windows 10",
browserName: "internet explorer"
});
}
safari && browsers.push("Safari");
edge && browsers.push("Edge");
ie && browsers.push("IE");

return config;
}
32 changes: 0 additions & 32 deletions src/types/karma-sauce-launcher/index.d.ts

This file was deleted.

2 changes: 0 additions & 2 deletions test/fixtures/mocha-hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ let envDefaults = {
KARMA_CI: "",
CI: "",
CI_BUILD_NUMBER: "",
SAUCE_USERNAME: "",
SAUCE_ACCESS_KEY: "",
GITHUB_ACTIONS: "",
};

Expand Down
Loading