This repo runs Playwright tests on BrowserStack Automate using the browserstack-node-sdk. A GitHub Actions workflow runs the tests on every push/PR, hourly, nightly, and on demand.
| Path | Purpose |
|---|---|
.github/workflows/browserstack-tests.yml |
CI workflow (push, PR, schedules, manual) |
browserstack.yml |
BrowserStack config: platforms, parallels, build name, credentials |
playwright.config.js |
Playwright config (tests in module*/**/*.js) |
moduleA/, moduleB/, moduleC/ |
Test files |
- On this repository's GitHub page, click Use this template → Create a new repository. Choose your own organization/account and set visibility to Private. (If you don't see the button, ask the owner to enable Settings → General → Template repository, or download this repo as a ZIP and push it to a new repo you own.)
- Open your new repository. Everything below (secrets, Actions, schedules) is configured there, not in the template.
- Optionally clone it locally:
git clone https://github.com/<your-org>/<your-repo>.git cd <your-repo>
- Get your Username and Access Key from BrowserStack Account Settings.
- In GitHub, go to Settings → Secrets and variables → Actions → New repository secret.
- Add two secrets:
BROWSERSTACK_USERNAMEBROWSERSTACK_ACCESS_KEY
Credentials are never stored in the code: browserstack.yml reads them from environment variables.
Open the Actions tab. If prompted, click "I understand my workflows, go ahead and enable them".
| Trigger | When | Build name on BrowserStack |
|---|---|---|
| Push / Pull request | On changes to main |
ci-run |
| Hourly schedule | 0 * * * * (minute 0 of every hour, UTC) |
hourly-run |
| Nightly schedule | 0 0 * * * (00:00 UTC daily) |
nightly-run |
| Manual | Actions → BrowserStack Playwright Tests → Run workflow | manual-run / hourly-run / nightly-run (chosen input) |
Build names appear on the Automate dashboard next to projectName: BrowserStack Samples, with an incrementing #<build number>. Filter by build name to separate hourly, nightly, and CI results.
Edit the cron entries under on.schedule in .github/workflows/browserstack-tests.yml. Cron times are UTC. Examples:
- Every 30 minutes:
*/30 * * * * - Nightly at 02:30 UTC:
30 2 * * * - Weekdays only, hourly:
0 * * * 1-5
If you change a cron expression, also update the matching string in the BROWSERSTACK_BUILD_NAME expression so the build label stays correct.
Notes on scheduled workflows
- Schedules only run from the default branch (
main).- GitHub may delay scheduled runs by several minutes during peak load; they are not guaranteed to start exactly on the hour.
- In public repos, schedules are disabled after 60 days of repo inactivity; re-enable them from the Actions tab.
- GitHub: Actions tab → select a run → logs and the uploaded
test-artifacts-<run id>artifact. - BrowserStack: Automate dashboard and Test Observability (enabled via
testObservability: true) for videos, logs, and screenshots.
- Browsers/OS: edit the
platformslist inbrowserstack.yml(full list). - Parallelism: set
parallelsPerPlatforminbrowserstack.yml. Total parallels = platforms ×parallelsPerPlatform. Make sure this fits your BrowserStack plan (calculator). - Your own tests: add specs under
moduleA/,moduleB/,moduleC/(or changetestMatchinplaywright.config.js). - Local/private sites: set
browserstackLocal: trueinbrowserstack.yml(docs).
export BROWSERSTACK_USERNAME=<your-username>
export BROWSERSTACK_ACCESS_KEY=<your-access-key>
export BROWSERSTACK_BUILD_NAME=local-run
npm install
npm run sample-test| Symptom | Fix |
|---|---|
| Authentication failed / 401 | Re-check the two secrets' names and values |
| Scheduled run not starting | Confirm workflow is on main and Actions are enabled |
| Tests queued on BrowserStack | Reduce parallelsPerPlatform/platforms or upgrade parallels |
| Hourly and nightly overlap at 00:00 | Expected; both run, using separate builds |