Skip to content

Add Cucumber-JS + Playwright BrowserStack SDK sample#3

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

Add Cucumber-JS + Playwright BrowserStack SDK sample#3
saraswati-padmawar wants to merge 9 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)

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.

osho-20
osho-20 previously approved these changes Jul 7, 2026
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.
Comment thread .github/workflows/sanity-workflow.yml Fixed
Comment thread .github/workflows/sanity-workflow.yml Fixed
@saraswati-padmawar

Copy link
Copy Markdown
Author

Claude Code PR Review

PR: #3Head: 37637b0Reviewers: stack:code-reviewer

Summary

Populates this previously-skeleton sample repo with a working Cucumber-JS + Playwright sample driven by the BrowserStack Node SDK (public bstackdemo add-to-cart + BrowserStack Local scenarios). Verified green on real BrowserStack sessions across 3 platforms.

Review Table

Priority Category Check Status Notes
High Security No hardcoded secrets or credentials Pass YOUR_USERNAME/YOUR_ACCESS_KEY are intended placeholders; workflow uses org secrets
High Security Authentication/authorization checks present N/A Sample test project
High Security Input validation and sanitization N/A No user input surface
High Security No IDOR — resource ownership validated N/A
High Security No SQL injection (parameterized queries) N/A No DB
High Correctness Logic is correct, handles edge cases Pass Steps + assertions confirmed by green verification build
High Correctness Error handling is explicit, no swallowed exceptions Pass Hooks close context/page/browser in After/AfterAll
High Correctness No race conditions or concurrency issues Pass Single browser in BeforeAll, per-scenario context/page
Medium Testing New code has corresponding tests Pass The sample is the test; verified passing
Medium Testing Error paths and edge cases tested N/A Sample scope
Medium Testing Existing tests still pass (no regressions) Pass Fresh repo
Medium Performance No N+1 queries or unbounded data fetching N/A
Medium Performance Long-running tasks use background jobs N/A
Medium Quality Follows existing codebase patterns Pass Matches standardized Automate SDK template
Medium Quality Changes are focused (single concern) Pass
Low Quality Meaningful names, no dead code Pass
Low Quality Comments explain why, not what Pass yml comments explain SDK routing
Low Quality No unnecessary dependencies added Pass @cucumber/cucumber pinned ^11 for Node 18/20

Findings

README.md / features/local.feature Medium — Local test not runnable as documented (no server on :45454) Resolved — fixed in 37637b0: README now documents serving a local page on 45454 and adapting to your own app.

  • File: .github/workflows/sanity-workflow.yml:19

  • Severity: Low

  • Reviewer: stack:code-reviewer

  • Issue: CI matrix only exercises Node 20, though the README advertises 18/20/22 (the whole point of the Cucumber v11 pin).

  • Suggestion: expand the matrix to ['18','20','22'] to actually guard the claim, or keep the "verified on Node 20" caveat as the scope.

  • File: package.json:16

  • Severity: Low

  • Reviewer: stack:code-reviewer

  • Issue: @playwright/test and browserstack-node-sdk float on latest with package-lock.json gitignored → non-reproducible builds. (Consistent with the BrowserStack sample convention; noted so it's a conscious choice. Cucumber is pinned while these float.)

  • Suggestion: optionally pin to a floating-minor for reproducibility.

  • File: package.json:12

  • Severity: Low

  • Reviewer: stack:code-reviewer

  • Issue: boilerplate author: "", and license: "ISC" declared without a LICENSE file.

  • Suggestion: set author / add LICENSE, or drop the field. Cosmetic.


Verdict: PASS — clean, template-conformant, and verified green on BrowserStack; only Low-severity polish remains and the one Medium is already resolved.

Review run via the BrowserStack AI harness stack:pr-review methodology (harness not installed in the run environment → independent stack:code-reviewer fallback).

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.
Comment thread browserstack.yml Outdated
Comment thread browserstack.yml
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).
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.

5 participants