Skip to content

Commit

Permalink
Replace saucelabs with browserstack
Browse files Browse the repository at this point in the history
  • Loading branch information
edoardocavazza committed Dec 1, 2023
1 parent e77bbc9 commit f3fce0f
Show file tree
Hide file tree
Showing 8 changed files with 126 additions and 404 deletions.
27 changes: 11 additions & 16 deletions .github/workflows/lint_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout the repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Setup Node
uses: actions/setup-node@v4
Expand Down Expand Up @@ -87,7 +87,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout the repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Setup Node
uses: actions/setup-node@v4
Expand All @@ -109,10 +109,10 @@ jobs:
token: ${{ secrets.CODECOV_TOKEN }}
file: coverage/clover.xml

test-saucelabs:
name: Test Saucelabs
test-browserstack:
name: Test Browserstack
runs-on: ubuntu-latest
concurrency: saucelabs
concurrency: browserstack
strategy:
max-parallel: 2
matrix:
Expand All @@ -125,13 +125,13 @@ jobs:
- 'firefox-latest-1'
- 'firefox-latest-2'
- 'firefox-90'
# - 'safari-latest'
# - 'safari-latest-1'
- 'safari-latest'
- 'safari-16'
- 'safari-14'
- 'edge-latest'
steps:
- name: Checkout the repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Setup Node
uses: actions/setup-node@v4
Expand All @@ -144,15 +144,10 @@ jobs:
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: true

- name: Run tests
uses: nick-fields/retry@v2
with:
timeout_minutes: 10
max_attempts: 2
retry_on: error
command: yarn test:saucelabs --browser.name sauce:${{ matrix.browser }} --coverage
run: yarn test:browserstack --browser.name browserstack:${{ matrix.browser }} --coverage
env:
SAUCE_USERNAME: ${{ secrets.SAUCE_USERNAME }}
SAUCE_ACCESS_KEY: ${{ secrets.SAUCE_ACCESS_KEY }}
BROWSERSTACK_USERNAME: ${{ secrets.BROWSERSTACK_USERNAME }}
BROWSERSTACK_ACCESS_KEY: ${{ secrets.BROWSERSTACK_ACCESS_KEY }}

- name: Upload coverage to codecov
uses: codecov/codecov-action@v3
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ public
tsconfig.tsbuildinfo
docs/.vitepress/dist
docs/.vitepress/cache
local.log
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"test": "yarn test:typings && yarn test:browser && yarn test:node",
"test:typings": "tsc -p test-typings --noEmit",
"test:browser": "vitest run --config vitest.browser.ts",
"test:saucelabs": "vitest run --config vitest.saucelabs.ts",
"test:browserstack": "vitest run --config vitest.browserstack.ts",
"test:node": "vitest run --config vitest.node.ts",
"lint": "prettier --check . && eslint src test",
"docs:dev": "vitepress dev docs",
Expand All @@ -62,6 +62,7 @@
"@vitest/coverage-istanbul": "^1.0.0-beta.5",
"@vitest/coverage-v8": "^1.0.0-beta.5",
"@vitest/ui": "^0.34.6",
"browserstack-local": "^1.5.5",
"esbuild": "^0.19.4",
"eslint": "^8.0.0",
"eslint-plugin-jsdoc": "^39.3.2",
Expand All @@ -70,8 +71,7 @@
"prettier": "^3.0.3",
"publint": "^0.2.3",
"rimraf": "^5.0.2",
"saucelabs": "^7.4.0",
"svelte": "^4.2.7",
"tslib": "^2.6.2",
"typescript": "^5.0.0",
"vitepress": "^1.0.0-rc.25",
"vitest": "^1.0.0-beta.5",
Expand Down
31 changes: 2 additions & 29 deletions test/providers/vitest-browserstack-provider.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,6 @@
import { Local, type Options } from 'browserstack-local';
import ip from 'ip';
import type { Task } from 'vitest';
import { remote, type Browser, type RemoteOptions } from 'webdriverio';

/**
* Check if a test of the suite has failed.
* @param suite List of tasks.
* @returns Whetever the suite failed or not.
* @see https://github.com/vitest-dev/vitest/blob/main/packages/runner/src/utils/tasks.ts
*/
function hasFailed(suite: Task[]): boolean {
return suite.some((s) => !s.result || s.result.state === 'fail' || (s.type === 'suite' && hasFailed(s.tasks)));
}
import { remote, type RemoteOptions } from 'webdriverio';

/**
* A BrowserStack provider for vitest.
Expand All @@ -29,7 +18,7 @@ export default class BrowserStackProvider {
protected bsOptions: Partial<Options>;
protected capabilities: RemoteOptions['capabilities'];

private _browserPromise: Promise<Browser> | null = null;
private _browserPromise: Promise<WebdriverIO.Browser> | null = null;
private _tunnelPromise: Promise<() => Promise<void>> | null = null;

getSupportedBrowsers() {
Expand Down Expand Up @@ -147,22 +136,6 @@ export default class BrowserStackProvider {
if (this._browserPromise) {
const browser = await this._browserPromise;
await browser.deleteSession();

// const { user, key } = this.browserstackOptions;
// if (user && key) {
// const files = this.ctx.state.getFiles();
// const passed = !!files.length && !hasFailed(Array.from(files));
// await fetch(`https://saucelabs.com/rest/v1/${user}/jobs/${browser.sessionId}`, {
// method: 'PUT',
// headers: {
// 'Authorization': `Basic ${Buffer.from(`${user}:${key}`).toString('base64')}`,
// 'Content-Type': 'application/json',
// },
// body: JSON.stringify({
// passed,
// }),
// });
// }
}
} catch {
//
Expand Down
14 changes: 0 additions & 14 deletions test/providers/vitest-saucelabs-provider.d.ts

This file was deleted.

191 changes: 0 additions & 191 deletions test/providers/vitest-saucelabs-provider.ts

This file was deleted.

Loading

0 comments on commit f3fce0f

Please sign in to comment.