Add Jest + Playwright BrowserStack SDK sample#2
Conversation
Sample test (bstackdemo add-to-cart) + local test (BrowserStack Local via bs-local.com:45454), browserstack.yml, package.json with browserstack-node-sdk run scripts, and README. Follows the standardized Automate sample template. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The Node SDK's jest flow gates Playwright support on resolving @playwright/test
from node_modules (src/bin/jest/command.js: getPackageVersion('@playwright/test')).
With only 'playwright' installed, detection never fired, the SDK skipped its
BrowserType.launch patch, and chromium.launch() ran locally instead of routing to
BrowserStack. Switch the dependency and imports to @playwright/test.
Verified: chromium.launch() now routes to wss://cdp.browserstack.com/playwright.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Mirrors browserstack/node-js-playwright-browserstack. Runs the public bstackdemo sample test + BrowserStack Local test against a python http.server harness, using org BROWSERSTACK_USERNAME/ACCESS_KEY secrets. Strips yml credential placeholders so the secrets take effect. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Rohannagariya1
left a comment
There was a problem hiding this comment.
LGTM ✅ — public scenario verified and the sample is clean. Approving.
One thing worth confirming before merge (non-blocking on the code itself):
- The Local scenario is unverified due to the SDK tunnel not being connected when the parallel Jest workers call
chromium.launch(). The "passes in the cucumber/nunit siblings" argument doesn't fully carry over since those aren't multi-worker Jest — the tunnel-startup vs parallel-worker race can reproduce on the runner too. Please confirm the sanity workflow is green on the Local step before merging; if it flakes,maxWorkers: 1injest.local.config.jswould serialize the workers and sidestep it.
Optional/minor:
latestdeps +postinstall: npm update+ gitignored lockfile = non-reproducible installs (matches BrowserStack sample convention, fine to keep).
The Local scenario navigates to bs-local.com:45454 and asserts the page title contains 'BrowserStack Local', but the README never told users to serve anything on that port -- so following it verbatim failed. Document serving a matching local page (and how to point at your own app), and describe the tunnel routing accurately.
8e7c834
Claude Code PR ReviewPR: #2 • Head: 8e7c834 • Reviewers: stack:code-reviewer SummaryPopulates this previously-skeleton sample repo with a working Jest + Playwright sample driven by the BrowserStack Node SDK. The public bstackdemo scenario is verified green across 3 platforms; the BrowserStack Local scenario is pending CI confirmation. Review Table
Findings
Verdict: PASS — no High/Critical issues; the public scenario is verified green, testMatch and SDK-detection logic are correct, and the workflow has no injection risk. Confirm the Local step on CI before merge. Review run via the BrowserStack AI harness |
Semgrep's supply-chain rule (action not pinned to a full commit SHA) blocks on unpinned tag refs like actions/checkout@v4. Pin all actions to SHAs with a version comment, matching the repo's Semgrep.yml. Also modernizes v3->v4.
Reviewer specified the onboarding-funnel source tag as <repo>:main:v1.0 -- the middle segment is the branch the sample lives on (main), not the 'sample-sdk' label.
…ecklist
The canonical format (Confluence ENG/4080468210) is {f/w-name}:sample-{branch-name}:v{version}.
The sample lives on main, so the branch segment is sample-main (keeps the sample- prefix).
Populates this customer-facing sample repo (previously skeleton: README + CODEOWNERS + Semgrep only) with a working Jest + Playwright sample driven by the BrowserStack Node SDK.
What's included
tests/bstack_sample.test.js— public bstackdemo.com add-to-cart scenariotests/bstack_local_test.test.js— BrowserStack Local scenario (bs-local.com:45454)browserstack.yml— credentials, 3 platforms (Win/Chrome, macOS/WebKit, Win/Firefox), Local toggle,framework: playwright,testReporting: truepackage.json—sample-test/sample-local-testscripts viabrowserstack-node-sdk jestjest.config.js/jest.local.config.js,.gitignore, READMEReferences
framework-matrix.md(browserstack-node-sdk jest)framework: playwrightmirrors the existingcodecept-js-playwright-browserstackprecedentnode-js-playwright-browserstackVerified on BrowserStack
Project: BrowserStack Samples.
🤖 Generated with Claude Code