Browserstack Service
A WebdriverIO service that manages local tunnel and job metadata for BrowserStack users.
Installation
The easiest way is to keep @wdio/browserstack-service
as a devDependency in your package.json
, via:
npm install @wdio/browserstack-service --save-dev
Instructions on how to install WebdriverIO
can be found here.
Configuration
WebdriverIO has BrowserStack support out of the box. You should set user
and key
in your wdio.conf.js
file. This service plugin provides support for BrowserStack Tunnel. Set browserstackLocal: true
also to activate this feature.
Reporting of session status on BrowserStack will respect strict
setting of Cucumber options.
// wdio.conf.js
export const config = {
// ...
user: process.env.BROWSERSTACK_USERNAME,
key: process.env.BROWSERSTACK_ACCESS_KEY,
services: [
['browserstack', {
testObservability: true,
testObservabilityOptions: {
projectName: "Your project name goes here",
buildName: "The static build job name goes here e.g. Nightly regression"
},
browserstackLocal: true
}]
],
// ...
};
Options
In order to authorize to the BrowserStack service your config needs to contain a user
and key
option.
testObservability
Test Observability is an advanced test reporting tool that gives insights to improve your automation tests and helps you debug faster. It’s enabled by default by setting the testObservability
flag as true
for all users of browserstack-service. You can disable this by setting the testObservability
flag to false
.
Once your tests finish running, you can visit Test Observability to debug your builds with additional insights like Unique Error Analysis, Automatic Flaky Test Detection, and more.
You can use Test Observability even if you don’t run your tests on the BrowserStack infrastructure. Even if you run your tests on a CI, a local machine, or even on other cloud service providers, Test Observability can still generate intelligent test reports and advanced analytics on your tests.
If you want to use Test Observability without running your tests on BrowserStack infrastructure, you can set your config as follows:
// wdio.conf.js
export const config = {
// ...
services: [
['browserstack', {
testObservability: true,
testObservabilityOptions: {
user: process.env.BROWSERSTACK_USERNAME,
key: process.env.BROWSERSTACK_ACCESS_KEY,
projectName: "Your project name goes here",
buildName: "The static build job name goes here e.g. Nightly regression"
}
}]
],
// ...
};
You can explore all the features of Test Observability in this sandbox or read more about it here.
browserstackLocal
Set this to true to enable routing connections from BrowserStack cloud through your computer.
Type: Boolean
Default: false
forcedStop
Set this to true to kill the BrowserStack Local process on complete, without waiting for the BrowserStack Local stop callback to be called. This is experimental and should not be used by all. Mostly necessary as a workaround for this issue.
Type: Boolean
Default: false
app
Appium set this with the app file path available locally on your machine to use the app as application under test for Appium sessions.
Type: String
or JsonObject
Default: undefined
List of available app values:
path
Use locally available app file path as an application under test for Appium.
services: [
['browserstack', {
app: '/path/to/local/app.apk'
// OR
app: {
path: '/path/to/local/app.apk'
}
}]
]
Pass custom_id while the app upload.
services: [
['browserstack', {
app: {
path: '/path/to/local/app.apk',
custom_id: 'custom_id'
}
}]
]
id
Use the app URL returned after uploading the app to BrowserStack.
services: [
['browserstack', {
app: 'bs://<app-id>'
// OR
app: {
id: 'bs://<app-id>'
}
}]
]
custom_id
use custom_id of already uploaded apps
services: [
['browserstack', {
app: 'custom_id'
// OR
app: {
custom_id: 'custom_id'
}
}]
]
shareable_id
use shareable_id of already uploaded apps
services: [
['browserstack', {
app: 'username/custom_id'
// OR
app: {
shareable_id: 'username/custom_id'
}
}]
]
preferScenarioName
Cucumber only. Set the BrowserStack Automate session name to the Scenario name if only a single Scenario ran. Useful when running in parallel with wdio-cucumber-parallel-execution.
Type: Boolean
Default: false
sessionNameFormat
Customize the BrowserStack Automate session name format.
Type: Function
Default (Cucumber/Jasmine): (config, capabilities, suiteTitle) => suiteTitle
Default (Mocha): (config, capabilities, suiteTitle, testTitle) => suiteTitle + ' - ' + testTitle