This repo contains samples for running Playwright tests on BrowserStack using the browserstack-node-sdk.
- Clone the repo
git clone https://github.com/browserstack/browserstack-playwright-load-testing-sample.git. - Set your credentials as environment variables, as described in Set your credentials.
- Run
npm ito install the dependencies. - Open
browserstack-load.ymland update it with your load test configuration.
The BrowserStack CLI reads your credentials from environment variables. Copy your username and access key from Account Settings and export them in the shell you run the test from:
On macOS or Linux (bash or zsh), run the lines below. The second one prompts for the key without echoing it, so the key stays out of your shell history:
export BROWSERSTACK_USERNAME="<your-username>"
printf 'BrowserStack access key: '; read -rs BROWSERSTACK_ACCESS_KEY; echo; export BROWSERSTACK_ACCESS_KEYOn Windows, run these in PowerShell. The second line prompts for the key in the same way:
$env:BROWSERSTACK_USERNAME = "<your-username>"
$env:BROWSERSTACK_ACCESS_KEY = [System.Net.NetworkCredential]::new('', (Read-Host -AsSecureString 'BrowserStack access key')).PasswordThese variables last only for the current terminal session. If the CLI reports an authentication error, check that both are set in the terminal you run it from.
Never commit your credentials. Leave the userName and accessKey placeholders in browserstack-load.yml as they are (the environment variables override them), and keep your access key out of every file you push. If a key is ever exposed, regenerate it from Account Settings.
- To run the sample tests in parallel across the platforms specified in the
browserstack-load.yml, runnpx browserstack-cli load run.
- You can view your test results on the BrowserStack Load-Testing dashboard
