Skip to content

Commit

Permalink
feat(Saucelabs): Migate to saucelabs
Browse files Browse the repository at this point in the history
Removes all CBT config. Migrates to saucelabs

Export specific configs for desktop/mobile legacy/latest configs

BREAKING CHANGE:

- CBT configuration removed
- Some mobile legacy floor versions bumped
  • Loading branch information
cblanc committed Feb 19, 2020
1 parent 191ce48 commit f13416f
Show file tree
Hide file tree
Showing 3 changed files with 122 additions and 228 deletions.
36 changes: 27 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@
> Matrix of supported browsers for automated javascript testing
[![CircleCI](https://circleci.com/gh/ideal-postcodes/supported-browsers.svg?style=svg)](https://circleci.com/gh/ideal-postcodes/supported-browsers)
![Dependency Status](https://david-dm.org/ideal-postcodes/supported-browsers.svg)
[![npm version](https://badge.fury.io/js/%40ideal-postcodes%2Fsupported-browsers.svg)](https://badge.fury.io/js/%40ideal-postcodes%2Fsupported-browsers)
[![Release](https://github.com/ideal-postcodes/supported-browsers/workflows/npm%20Release/badge.svg)](https://github.com/ideal-postcodes/supported-browsers/actions)

`@ideal-postcodes/supported-browsers` exports a matrix of supported browsers

- Browser exports for [Cross Browser Testing](https://crossbrowsertesting.com)
- Browser exports for [Saucelabs](https://saucelabs.com)

## Links

Expand All @@ -19,6 +18,31 @@

## Documentation

### Supported Browsers

#### Latest Desktop

- Chrome
- Safari
- Firefox
- Edge

#### Latest Mobile

- Safari (iOS 13.0)
- Chrome (Android)

#### Legacy Desktop

- Internet Explorer 11
- Firefox 48
- Chrome 43

#### Legacy Mobile

- Android Browser (Android 5.1)
- Safari (iOS 10.3)

### Configuration & Usage

```bash
Expand All @@ -27,13 +51,7 @@ npm install @ideal-postcodes/supported-browsers

```javascript
// Retrieve tested browser matrix
import { browsers, toCbtLaunchers } from "@ideal-postcodes/supported-browsers";

// Generate CBT launchers
toCbtLaunchers(browsers, {
name: "core-interface",
build: "gitsha",
});
import { browsers } from "@ideal-postcodes/supported-browsers";
```

## Test
Expand Down
214 changes: 76 additions & 138 deletions lib/index.ts
Original file line number Diff line number Diff line change
@@ -1,183 +1,121 @@
export type SupportMatrix = Record<string, Browser>;

export interface Browser {
export type Browser = MobileBrowser | DesktopBrowser;

interface DesktopBrowser {
base: "SauceLabs";
// Browser (e.g. IE, Chrome)
browserName: string;
// Browser version number and? bit version (e.g. 74x64)
version: string;
// Operating system and version (e.g. Windows 10)
platform?: string;
}

interface MobileBrowser {
base: "SauceLabs";
// Browser (e.g. IE, Chrome)
browserName: string;
// Browser version number and? bit version (e.g. 74x64)
version?: string;
version: string;
// Operating system and version (e.g. Windows 10)
platform?: string;
// Mobile device (e.g. iPhone 4s)
deviceName?: string;
// Mobile platform version (e.g. 9.0)
platformVersion?: string;
// Mobile platform name (e.g. Android)
platformName?: string;
// Mobile device orientation (e.g landscape)
deviceOrientation?: string;
// Our addition
desktop?: boolean;
mobile?: boolean;
legacy?: boolean;
latest?: boolean;
deviceName: string;
// Portrait or landscape
deviceOrientation: string;
}

/**
* Export supported browsers
*/
export const browsers: SupportMatrix = {
// Latest Desktop
const base = "SauceLabs";

export const latestDesktop: SupportMatrix = {
chrome: {
browserName: "Chrome",
version: "77x64",
platform: "Windows 10",
desktop: true,
latest: true,
base,
browserName: "chrome",
version: "latest",
},
firefox: {
browserName: "Firefox",
version: "69x64",
platform: "Windows 10",
desktop: true,
latest: true,
base,
browserName: "firefox",
version: "latest",
},
safari: {
browserName: "Safari",
version: "12",
platform: "Mac OSX 10.14",
desktop: true,
latest: true,
base,
browserName: "safari",
version: "latest",
},
edge: {
browserName: "MicrosoftEdge",
version: "18",
platform: "Windows 10",
desktop: true,
latest: true,
base,
browserName: "microsoftedge",
version: "latest",
},
};

// Legacy Desktop
export const legacyDesktop: SupportMatrix = {
ie: {
browserName: "Internet Explorer",
base,
browserName: "internet explorer",
version: "11",
platform: "Windows 10",
desktop: true,
legacy: true,
platform: "Windows 8.1",
},
"chrome-legacy": {
browserName: "Chrome",
version: "43",
base,
browserName: "chrome",
version: "43.0",
platform: "Windows 10",
desktop: true,
legacy: true,
},
"firefox-legacy": {
browserName: "Firefox",
version: "48",
base,
browserName: "firefox",
version: "48.0",
platform: "Windows 10",
desktop: true,
legacy: true,
},
};

// Latest Mobile
"android-latest": {
browserName: "Chrome",
deviceName: "Pixel 3",
platformVersion: "9.0",
platformName: "Android",
deviceOrientation: "portrait",
mobile: true,
legacy: true,
},
export const latestMobile: SupportMatrix = {
"ios-latest": {
base,
deviceOrientation: "portrait",
deviceName: "iPhone X Simulator",
browserName: "Safari",
deviceName: "iPad 6th Generation Simulator",
platformVersion: "12.0",
platformName: "iOS",
deviceOrientation: "landscape",
mobile: true,
legacy: true,
version: "13.0",
platform: "iOS",
},
"android-latest": {
base,
deviceName: "Android GoogleAPI Emulator",
deviceOrientation: "portrait",
browserName: "Chrome",
version: "5.1",
platform: "Android",
},
};

// Legacy Mobile
export const legacyMobile: SupportMatrix = {
"android-legacy": {
browserName: "Chrome",
deviceName: "Nexus 6",
platformVersion: "5.0",
platformName: "Android",
base,
browserName: "Browser",
deviceName: "Android GoogleAPI Emulator",
deviceOrientation: "portrait",
mobile: true,
legacy: true,
version: "5.1",
platform: "Android",
},
"ios-legacy": {
base,
browserName: "Safari",
deviceName: "iPhone 6s Plus Simulator",
platformVersion: "9.3",
platformName: "iOS",
deviceName: "iPhone SE Simulator",
deviceOrientation: "portrait",
mobile: true,
legacy: true,
version: "10.3",
platform: "iOS",
},
};

export type CbtLauncher = DesktopLauncher | MobileLauncher;

interface BuildInfo {
name: string;
build: string;
}

interface DesktopLauncher extends BuildInfo {
browserName: string;
base: "CrossBrowserTesting";
screenResolution: string;
version: string;
platform: string;
}

interface MobileLauncher extends BuildInfo {
browserName: string;
base: "CrossBrowserTesting";
deviceName: string;
platformVersion: string;
platformName: string;
deviceOrientation: string;
}

const base = "CrossBrowserTesting";
const screenResolution = "1366x768";

interface ToCbtLaunchers {
(matrix: SupportMatrix, buildInfo: BuildInfo): Record<string, CbtLauncher>;
}

/**
* Returns a map of custom CBT launchers compatible with karma-cbt-launcher
* given a browser support matrix and build information
* Export supported browsers
*/
export const toCbtLaunchers: ToCbtLaunchers = (matrix, buildInfo) => {
const launchers: Record<string, CbtLauncher> = {};
Object.entries(matrix).forEach(([key, browser]) => {
if (browser.mobile) {
launchers[key] = {
base,
...buildInfo,
browserName: browser.browserName,
deviceName: browser.deviceName || "",
platformVersion: browser.platformVersion || "",
platformName: browser.platformName || "",
deviceOrientation: browser.deviceOrientation || "",
};
} else {
launchers[key] = {
base,
screenResolution,
...buildInfo,
browserName: browser.browserName,
version: browser.version || "",
platform: browser.platform || "",
};
}
});
return launchers;
export const browsers: SupportMatrix = {
...latestDesktop,
...legacyDesktop,
...latestMobile,
...legacyMobile,
};

0 comments on commit f13416f

Please sign in to comment.