Skip to content

Add Jest sample for Selenium load testing#6

Merged
Ankit098 merged 4 commits into
mainfrom
add-jest-sample
Jun 10, 2026
Merged

Add Jest sample for Selenium load testing#6
Ankit098 merged 4 commits into
mainfrom
add-jest-sample

Conversation

@anushree-bstack

Copy link
Copy Markdown
Collaborator

Adds a jest/ folder mirroring the per-framework layout used by java/, junit-4/, junit-5/, and testng/. Tests use selenium-webdriver against the BrowserStack pod's hub at localhost:4444/wd/hub and target bstackdemo.com for add-to-cart and full checkout flows, parity with the WebdriverIO public sample.

  • jest/browserstack-load.yml — Selenium + framework: jest, vus: 1, duration: 1m, us-east-1, references jest.config.js
  • jest/package.json — jest + selenium-webdriver
  • jest/jest.config.js — node env, runInBand-friendly
  • jest/tests/add-to-cart.test.js — bstackdemo add-to-cart
  • jest/tests/checkout.test.js — bstackdemo full checkout flow
  • jest/README.md — 5-step setup (clone, npm install, CLI, run, dashboard)
  • .gitignore — Node artifacts (node_modules, lockfiles)

Adds a jest/ folder mirroring the per-framework layout used by
java/, junit-4/, junit-5/, and testng/. Tests use selenium-webdriver
against the BrowserStack pod's hub at localhost:4444/wd/hub and target
bstackdemo.com for add-to-cart and full checkout flows, parity with
the WebdriverIO public sample.

- jest/browserstack-load.yml — Selenium + framework: jest, vus: 1,
  duration: 1m, us-east-1, references jest.config.js
- jest/package.json — jest + selenium-webdriver
- jest/jest.config.js — node env, runInBand-friendly
- jest/tests/add-to-cart.test.js — bstackdemo add-to-cart
- jest/tests/checkout.test.js — bstackdemo full checkout flow
- jest/README.md — 5-step setup (clone, npm install, CLI, run, dashboard)
- .gitignore — Node artifacts (node_modules, lockfiles)
@anushree-bstack anushree-bstack requested a review from a team as a code owner May 11, 2026 07:27

@jhawarchirag jhawarchirag left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Reviewed against the four existing samples (java/, junit-4/, junit-5/, testng/) to keep this consistent with what customers already see in the repo. Three changes needed before merge — all are parity gaps with the sibling samples, not new conventions:

  1. Checkout test has no expect() and a different final-step flow than siblings — see inline comment on checkout.test.js.
  2. Driver lifecycle is beforeAll/afterAll; siblings re-create per test.
  3. Implicit wait + window().maximize() missing.

Non-blocking (pre-existing repo-wide, not introduced by this PR but worth a follow-up): brittle selectors (#\\33, react-select-2-option-0-0, deep float-cart chain), hardcoded sleep(500) after login, README OS↔arch swap in Linux binary links. These appear in every sample — best handled in a separate cleanup PR across all frameworks.

Comment thread jest/tests/checkout.test.js Outdated
Comment thread jest/tests/add-to-cart.test.js
Comment thread jest/tests/add-to-cart.test.js
Ankit098 and others added 2 commits May 27, 2026 19:04
- Per-test driver lifecycle (beforeEach/afterEach) instead of beforeAll/afterAll
- Add 10s implicit wait + window maximize after build
- Assert on order confirmation message; drop trailing Continue/Orders xpath clicks

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Mirror the known-working load-testing-backend/sample/jest-selenium scripts:
- add-to-cart: wait for elements to be visible before reading text (fixes
  the empty cart-title race the reviewer hit), use the short descendant
  selector, beforeAll/afterAll session.
- checkout: wait for the cart overlay to open before closing, route the
  tail through Continue Shopping -> Orders, wrap interactions in
  located/visible/enabled waits.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@anushree-bstack

Copy link
Copy Markdown
Collaborator Author

Updated (1cdab4a) — aligned both jest tests with the proven load-testing-backend/sample/jest-selenium scripts, which were validated end-to-end via UI + CLI on a real load-test run.

add-to-cart.test.js

  • Wait for elements to be visible before reading their text — this is what fixes the empty cart-title (Expected "iPhone 12 Pro Max", Received "") that came up in local runs. The float-cart slides in with an animation, so the title node exists before its text is painted; reading too early returns "".
  • Switched to the shorter descendant selector for the cart title and a beforeAll/afterAll session.

checkout.test.js

  • Wait for the cart overlay to open before closing it.
  • Routed the tail through Continue Shopping → Orders, matching the working sample.
  • Wrapped interactions in located/visible/enabled waits.

Note: I haven't executed these locally (no Selenium hub on hand) — verified by matching the flow line-for-line against the known-working sample. Best to confirm with a CLI/pod run before merge.

@Ankit098 Ankit098 merged commit 2cee181 into main Jun 10, 2026
5 checks passed
@Ankit098 Ankit098 deleted the add-jest-sample branch June 10, 2026 11:19
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.

3 participants