Add Jest sample for Selenium load testing#6
Conversation
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)
jhawarchirag
left a comment
There was a problem hiding this comment.
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:
- Checkout test has no
expect()and a different final-step flow than siblings — see inline comment oncheckout.test.js. - Driver lifecycle is
beforeAll/afterAll; siblings re-create per test. - 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.
| await driver.findElement(By.id("postCodeInput")).sendKeys("pincode"); | ||
|
|
||
| // checkout | ||
| await driver.findElement(By.id("checkout-shipping-continue")).click(); |
There was a problem hiding this comment.
Missing assertion + wrong final-step flow
All four sibling samples (java/, junit-4/, junit-5/, testng/) end the checkout test by asserting on the order confirmation message:
String checkoutMessage = driver.findElement(By.id("confirmation-message")).getText();
assertEquals("Your Order has been successfully placed.", checkoutMessage);This jest version clicks checkout-shipping-continue → an xpath Continue → an xpath Orders and exits with no expect(). A silent failure mid-flow is the only signal a successful run gives — passing tests prove nothing.
Suggested change:
await driver.findElement(By.id("checkout-shipping-continue")).click();
const checkoutMessage = await driver
.findElement(By.id("confirmation-message"))
.getText();
expect(checkoutMessage).toBe("Your Order has been successfully placed.");Drop the two trailing xpath clicks — siblings do not have them.
| describe("BStackDemo test add to cart", () => { | ||
| let driver; | ||
|
|
||
| beforeAll(async () => { |
There was a problem hiding this comment.
Driver lifecycle should be per-test, not shared across the file
Sibling samples use @BeforeMethod / @BeforeEach / @Before — a fresh driver per @Test. This file uses beforeAll / afterAll, so both test() blocks share one session. State from add-to-cart leaks into checkout (cart contents, cookies, scroll position). Swap to beforeEach / afterEach for parity with the other framework samples. Same change needed in checkout.test.js.
| driver = await new Builder() | ||
| .usingServer(HUB_URL) | ||
| .forBrowser("chrome") | ||
| .build(); |
There was a problem hiding this comment.
Missing implicit wait + window maximize (sibling parity)
All sibling samples configure a 10-second implicit wait and maximize the window after driver build:
driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(10));
driver.manage().window().maximize();Without these, findElement races against page render — flakes the first run on a fresh pod. Add after .build():
await driver.manage().setTimeouts({ implicit: 10000 });
await driver.manage().window().maximize();Same change needed in checkout.test.js.
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.