Skip to content

Commit f85eadc

Browse files
Address review: sibling parity for jest sample
- 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>
1 parent db307da commit f85eadc

2 files changed

Lines changed: 12 additions & 10 deletions

File tree

jest/tests/add-to-cart.test.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,16 @@ const HUB_URL = "http://localhost:4444/wd/hub";
88
describe("BStackDemo test add to cart", () => {
99
let driver;
1010

11-
beforeAll(async () => {
11+
beforeEach(async () => {
1212
driver = await new Builder()
1313
.usingServer(HUB_URL)
1414
.forBrowser("chrome")
1515
.build();
16+
await driver.manage().setTimeouts({ implicit: 10000 });
17+
await driver.manage().window().maximize();
1618
});
1719

18-
afterAll(async () => {
20+
afterEach(async () => {
1921
if (driver) await driver.quit();
2022
});
2123

jest/tests/checkout.test.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,16 @@ const HUB_URL = "http://localhost:4444/wd/hub";
55
describe("BStackDemo test checkout flow", () => {
66
let driver;
77

8-
beforeAll(async () => {
8+
beforeEach(async () => {
99
driver = await new Builder()
1010
.usingServer(HUB_URL)
1111
.forBrowser("chrome")
1212
.build();
13+
await driver.manage().setTimeouts({ implicit: 10000 });
14+
await driver.manage().window().maximize();
1315
});
1416

15-
afterAll(async () => {
17+
afterEach(async () => {
1618
if (driver) await driver.quit();
1719
});
1820

@@ -45,11 +47,9 @@ describe("BStackDemo test checkout flow", () => {
4547

4648
// checkout
4749
await driver.findElement(By.id("checkout-shipping-continue")).click();
48-
await driver
49-
.findElement(By.xpath("//*[contains(text(),'Continue')]"))
50-
.click();
51-
await driver
52-
.findElement(By.xpath("//*[contains(text(),'Orders')]"))
53-
.click();
50+
const checkoutMessage = await driver
51+
.findElement(By.id("confirmation-message"))
52+
.getText();
53+
expect(checkoutMessage).toBe("Your Order has been successfully placed.");
5454
});
5555
});

0 commit comments

Comments
 (0)