Skip to content

Add Cucumber-JS + Playwright BrowserStack SDK sample#3

Open
saraswati-padmawar wants to merge 5 commits into
mainfrom
add-cucumber-js-playwright-sample
Open

Add Cucumber-JS + Playwright BrowserStack SDK sample#3
saraswati-padmawar wants to merge 5 commits into
mainfrom
add-cucumber-js-playwright-sample

Conversation

@saraswati-padmawar

@saraswati-padmawar saraswati-padmawar commented Jun 30, 2026

Copy link
Copy Markdown

Populates this customer-facing sample repo (previously skeleton: README + CODEOWNERS + Semgrep only) with a working Cucumber-JS + Playwright sample driven by the BrowserStack Node SDK.

What's included

  • features/sample.feature + step_definitions/sample_steps.js — public bstackdemo.com add-to-cart scenario
  • features/local.feature + step_definitions/local_steps.js — BrowserStack Local scenario (bs-local.com:45454)
  • features/support/hooks.js — launches Playwright per scenario (SDK routes the launch)
  • cucumber.jssample and local profiles
  • browserstack.yml — credentials, 3 platforms, Local toggle, framework: playwright, testReporting: true
  • package.json — scripts via browserstack-node-sdk cucumber-js --profile …, .gitignore, README

References

  • Follows the standardized Automate sample template (Confluence: SDK Sample Repo Generator, R1–R4)
  • SDK run command per the node-agent framework-matrix.md (browserstack-node-sdk cucumber-js); @cucumber/cucumber hook pattern from node-agent examples
  • framework: playwright mirrors the existing codecept-js-playwright-browserstack precedent

Verified on BrowserStack ✅

Both scenarios ran end-to-end against BrowserStack Automate (Node 20), passing on all 3 configured platforms (OS X Ventura/playwright-webkit, Windows 11/chrome, Windows 11/playwright-firefox):

Scenario Command Result Build
Public (bstackdemo add-to-cart) npm run sample-test ✅ 3/3 passed 497c7b68c924616a4f825cabe63dae140d141db6
BrowserStack Local (bs-local.com:45454) npm run sample-local-test ✅ 3/3 passed 3d8eb5f9164866878b39af7e638f24399dc1e4bd

The Local run confirms the SDK starts the tunnel and the cloud browser reaches a local-only page through bs-local.com (the title assertion passed). Project: BrowserStack Samples.

Notes from verification: the sample must depend on @playwright/test (not playwright) for the SDK to detect & route Playwright, and @cucumber/cucumber is pinned to v11 (v12 requires Node 22+). Both are reflected in this PR.

🤖 Generated with Claude Code

Sample feature (bstackdemo add-to-cart) + local feature (BrowserStack Local via
bs-local.com:45454) with step definitions and Playwright hooks, browserstack.yml,
cucumber.js profiles, 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>
@saraswati-padmawar saraswati-padmawar requested a review from a team as a code owner June 30, 2026 08:17
saraswati-padmawar and others added 4 commits June 30, 2026 14:04
The Node SDK's cucumber-js flow gates Playwright support on resolving
@playwright/test from node_modules (src/bin/cucumber-js/command.js:
getPackageVersion('@playwright/test')). With only 'playwright' installed,
detection never fired, the SDK skipped its BrowserType.launch patch, and
chromium.launch() would run locally instead of routing to BrowserStack.
Switch the dependency and import to @playwright/test.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Mirrors browserstack/node-js-playwright-browserstack. Runs the public bstackdemo
sample profile + BrowserStack Local profile 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>
@cucumber/cucumber@latest is v12, whose paths.js uses Node 22's fs/promises.glob.
On Node 18/20 that throws 'promises_1.glob is not a function' during path
resolution, so no scenario runs. v11 supports Node 18/20 (the sample's target
range). Verified: 3/3 platforms pass real BrowserStack sessions on Node 20.

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 Rohannagariya1 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM ✅ — clean, well-documented sample and both scenarios verified end-to-end. Approving.

A couple of low-risk, optional notes (non-blocking):

  • @playwright/test / browserstack-node-sdk pinned to latest + postinstall: npm update + package-lock.json gitignored means installs aren't reproducible. This matches BrowserStack's existing sample convention, so fine to keep — just flagging.
  • Sanity workflow is workflow_dispatch-only, so it won't gate the PR automatically; worth a manual trigger before merge.

Nice touch pinning @cucumber/cucumber to v11 with the Node-version rationale documented.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants