CircleCI with BrowserStack Load Testing
Integrate BrowserStack Load Testing into CircleCI pipelines to run load tests in your CI/CD workflows.
You can add BrowserStack Load Testing to your CircleCI pipelines so that every commit triggers a load test.
Prerequisites
Make sure you have the following before you start:
- A BrowserStack account with access to Load Testing.
- A CircleCI account connected to your GitHub or Bitbucket organization.
- A source repository (GitHub or Bitbucket) where CircleCI reads your
.circleci/config.yml. - CircleCI environment variables for your BrowserStack credentials. You can find the credentials on your account’s profile page:
-
BROWSERSTACK_USERNAME: Your BrowserStack username. -
BROWSERSTACK_ACCESS_KEY: Your BrowserStack access key.
-
To add the variables:
- Go to your project on CircleCI.
- In the top-right corner, click Project Settings.
- In the left sidebar, click Environment Variables.
- Click Add Environment Variable for each of the two credentials, enter the Name and Value, and click Add Environment Variable.
CircleCI automatically injects these into every job step.
To set up the project (first time):
- Sign in to CircleCI with your GitHub or Bitbucket account.
- Click Projects in the sidebar, find your repository, and click Set Up Project.
- Choose Use the .circleci/config.yml in my repo’s main branch.
- CircleCI runs the first pipeline immediately after setup.
CircleCI configuration
Use the following CircleCI configuration to download the BrowserStack CLI, run a sample Playwright-based load test, and upload JUnit XML reports as artifacts. Save it at .circleci/config.yml in your repository.
version: 2.1
jobs:
load-test:
docker:
- image: cimg/base:current
steps:
- checkout
- run:
name: Verify BrowserStack credentials are set
command: |
: "${BROWSERSTACK_USERNAME:?set in Project Settings → Environment Variables}"
: "${BROWSERSTACK_ACCESS_KEY:?set in Project Settings → Environment Variables}"
- run:
name: Run unit tests
command: echo "Running unit tests"
- run:
name: Download BrowserStack CLI
command: |
OS=$(uname -s); ARCH=$(uname -m)
[ "$OS" = "Darwin" ] && OS=macos || OS=linux
case "$ARCH" in *arm*) ARCH=arm64 ;; *) ARCH=x64 ;; esac
curl -fL "https://load-api.browserstack.com/api/v1/binary?os=${OS}&arch=${ARCH}" -o browserstack-cli.zip
unzip -oq browserstack-cli.zip
chmod +x browserstack-cli
- run:
name: Checkout sample Playwright project
command: |
curl -L https://github.com/browserstack/browserstack-playwright-load-testing-sample/archive/refs/heads/CI/CD-Sample-Playwright.tar.gz \
| tar -xz --strip-components=1
- run:
name: Run BrowserStack load test
command: ./browserstack-cli load run
- store_artifacts:
path: .
destination: load-test-output
- store_test_results:
path: .
workflows:
version: 2
build-and-load-test:
jobs:
- load-test
Result
When this pipeline runs, it:
- Downloads the BrowserStack CLI for the current runner OS and architecture.
- Fetches the BrowserStack Playwright load-testing sample project.
- Starts a BrowserStack Load Testing run using your BrowserStack credentials.
- Stores the working directory as a CircleCI artifact and JUnit XML reports under the Tests tab.
Notes
- CircleCI free tier provides 6,000 build minutes per month; more than enough for routine load-test runs.
- The default
cimg/base:currentDocker image is Linux x64. For macOS or Windows resource classes, you need a paid plan. - For organization-wide shared credentials, use Contexts (Organization Settings → Contexts) instead of per-project environment variables, then attach the context to the workflow under
workflows.<workflow>.jobs.<job>.context.
We're sorry to hear that. Please share your feedback so we can do better
Contact our Support team for immediate help while we work on improving our docs.
We're continuously improving our docs. We'd love to know what you liked
We're sorry to hear that. Please share your feedback so we can do better
Contact our Support team for immediate help while we work on improving our docs.
We're continuously improving our docs. We'd love to know what you liked
Thank you for your valuable feedback!