Skip to content

Commit

Permalink
Add vitest-provider-browserstack documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
edoardocavazza committed Mar 6, 2024
1 parent ff2e84e commit 1a248c2
Show file tree
Hide file tree
Showing 4 changed files with 161 additions and 5 deletions.
4 changes: 4 additions & 0 deletions docs/.vitepress/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,10 @@ export default defineConfig({
text: 'postcss-url-rebase',
link: '/guide/postcss-url-rebase',
},
{
text: 'vitest-provider-browserstack',
link: '/guide/vitest-provider-browserstack',
},
// {
// text: 'Write a plugin',
// link: '/guide/write-a-plugin',
Expand Down
88 changes: 88 additions & 0 deletions docs/guide/vitest-provider-browserstack.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
# Browserstack provider for Vitest

A browser provider for [Vitest](https://vitest.dev/) that runs tests on [Browserstack](https://www.browserstack.com/).

### Install

::: code-group

```sh[npm]
npm i -D @chialab/vitest-provider-browserstack
```

```sh[yarn]
yarn add -D @chialab/vitest-provider-browserstack
```

```sh[pnpm]
pnpm add -D @chialab/vitest-provider-browserstack
```

:::

### Requirements

In order to use this provider, you need to have a Browserstack account and a valid access key.

### Usage

Use this module as provider for Vitest browser runner:

```ts
/// <reference types="@chialab/vitest-provider-browserstack" />

export default {
test: {
browser: {
name: 'browserstack:chrome-latest',
// Use the browserstack provider.
provider: '@chialab/vitest-provider-browserstack',
// We need to expose the server to the network in order to let Browserstack access it.
api: {
host: '0.0.0.0',
port: 5176,
},
// Hijack ESM imports is unstable on older browsers.
slowHijackESM: false,
},
},
browserstack: {
options: {
user: 'YOUR_BROWSERSTACK_USERNAME',
key: 'YOUR_BROWSERSTACK_ACCESS_KEY',
},
capabilities: {
'chrome-latest': {
'browserName': 'Chrome',
'bstack:options': {
browserVersion: 'latest',
},
},
'firefox-latest': {
'browserName': 'Firefox',
'bstack:options': {
browserVersion: 'latest',
},
},
'safari-latest': {
'browserName': 'Safari',
'bstack:options': {
browserVersion: 'latest',
},
},
'edge-latest': {
'browserName': 'MicrosoftEdge',
'bstack:options': {
browserVersion: 'latest',
},
},
},
},
};
```

### Options

`user` and `key` options can be omitted if you have a `BROWSERSTACK_USERNAME` and `BROWSERSTACK_ACCESS_KEY` environment variables set.

Read more about the capabilities configuration at [Browserstack documentation](https://www.browserstack.com/docs/automate/capabilities) and Webdriverio [capabilities](https://webdriver.io/docs/capabilities/).
66 changes: 63 additions & 3 deletions packages/vitest-provider-browserstack/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<p align="center">
<strong>vitest-provider-browserstack</strong> • A BrowserStack provider for vitest browser runner.
<strong>Browserstack provider for Vitest</strong> • A BrowserStack provider for Vitest browser runner.
</p>

<p align="center">
Expand All @@ -18,13 +18,73 @@ npm i @chialab/vitest-provider-browserstack -D
yarn add @chialab/vitest-provider-browserstack -D
```

## Requirements

In order to use this provider, you need to have a Browserstack account and a valid access key.

## Usage

```js
import '@chialab/vitest-provider-browserstack';
Use this module as provider for Vitest browser runner:

```ts
/// <reference types="@chialab/vitest-provider-browserstack" />

export default {
test: {
browser: {
name: 'browserstack:chrome-latest',
// Use the browserstack provider.
provider: '@chialab/vitest-provider-browserstack',
// We need to expose the server to the network in order to let Browserstack access it.
api: {
host: '0.0.0.0',
port: 5176,
},
// Hijack ESM imports is unstable on older browsers.
slowHijackESM: false,
},
},
browserstack: {
options: {
user: 'YOUR_BROWSERSTACK_USERNAME',
key: 'YOUR_BROWSERSTACK_ACCESS_KEY',
},
capabilities: {
'chrome-latest': {
'browserName': 'Chrome',
'bstack:options': {
browserVersion: 'latest',
},
},
'firefox-latest': {
'browserName': 'Firefox',
'bstack:options': {
browserVersion: 'latest',
},
},
'safari-latest': {
'browserName': 'Safari',
'bstack:options': {
browserVersion: 'latest',
},
},
'edge-latest': {
'browserName': 'MicrosoftEdge',
'bstack:options': {
browserVersion: 'latest',
},
},
},
},
};
```

## Options

`user` and `key` options can be omitted if you have a `BROWSERSTACK_USERNAME` and `BROWSERSTACK_ACCESS_KEY` environment variables set.

Read more about the capabilities configuration at [Browserstack documentation](https://www.browserstack.com/docs/automate/capabilities) and Webdriverio [capabilities](https://webdriver.io/docs/capabilities/).

---

## License
Expand Down
8 changes: 6 additions & 2 deletions packages/vitest-provider-browserstack/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@chialab/vitest-provider-browserstack",
"type": "module",
"version": "0.18.0",
"description": "A BrowserStack provider for vitest browser runner.",
"description": "A BrowserStack provider for Vitest browser runner.",
"main": "lib/index.js",
"typings": "./types/index.d.ts",
"author": "Chialab <[email protected]> (https://www.chialab.it)",
Expand All @@ -12,7 +12,11 @@
"url": "https://github.com/chialab/rna",
"directory": "packages/vitest-provider-browserstack"
},
"keywords": [],
"keywords": [
"vitest",
"browserstack",
"webdriver"
],
"files": [
"lib",
"types",
Expand Down

0 comments on commit 1a248c2

Please sign in to comment.