Skip to content

Commit b7ceaca

Browse files
committed
Add speeding up stage 3
1 parent 352769d commit b7ceaca

4 files changed

Lines changed: 143 additions & 74 deletions

File tree

‎playwright.config.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export default defineConfig({
3333
// baseURL: "http://localhost:3000",
3434

3535
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
36-
trace: "on",
36+
trace: "retain-on-failure",
3737
},
3838

3939
/* Configure projects for major browsers */

‎tests/plan-upgrade.spec.ts‎

Lines changed: 77 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -1,85 +1,89 @@
11
import { expect, test } from "@playwright/test";
2+
import { testWithNewUser } from "./test-with-new-user";
23

34
test.describe("Plan Upgrade Flow", () => {
4-
test("should successfully upgrade from Free to Plus plan", async ({
5-
page,
6-
}) => {
7-
await test.step("Navigate to dashboard and verify initial state", async () => {
8-
await page.goto("/dashboard");
9-
await expect(page).toHaveTitle("Playwright Tutorial");
10-
await expect(
11-
page.getByRole("heading", { name: "Team Settings" }),
12-
).toBeVisible();
13-
});
5+
testWithNewUser(
6+
"should successfully upgrade from Free to Plus plan",
7+
async ({ page }) => {
8+
await test.step("Navigate to dashboard and verify initial state", async () => {
9+
await page.goto("/dashboard");
10+
await expect(page).toHaveTitle("Playwright Tutorial");
11+
await expect(
12+
page.getByRole("heading", { name: "Team Settings" }),
13+
).toBeVisible();
14+
});
1415

15-
await test.step("Verify current plan is Free", async () => {
16-
await expect(page.getByText("Current Plan: Free")).toBeVisible();
17-
await expect(page.getByText("No active subscription")).toBeVisible();
18-
});
16+
await test.step("Verify current plan is Free", async () => {
17+
await expect(page.getByText("Current Plan: Free")).toBeVisible();
18+
await expect(page.getByText("No active subscription")).toBeVisible();
19+
});
1920

20-
await test.step("Navigate to pricing page", async () => {
21-
await page.getByRole("link", { name: "Change Plan" }).click();
22-
await expect(page).toHaveURL(/.*\/pricing$/);
23-
await expect(
24-
page.getByRole("heading", { name: "Choose Your Plan" }),
25-
).toBeVisible();
26-
});
21+
await test.step("Navigate to pricing page", async () => {
22+
await page.getByRole("link", { name: "Change Plan" }).click();
23+
await expect(page).toHaveURL(/.*\/pricing$/);
24+
await expect(
25+
page.getByRole("heading", { name: "Choose Your Plan" }),
26+
).toBeVisible();
27+
});
2728

28-
await test.step("Verify available plans and select Plus plan", async () => {
29-
await expect(page.getByRole("heading", { name: "Base" })).toBeVisible();
30-
await expect(page.getByRole("heading", { name: "Plus" })).toBeVisible();
31-
await page.getByRole("button", { name: "Get Started" }).nth(1).click();
32-
});
29+
await test.step("Verify available plans and select Plus plan", async () => {
30+
await expect(page.getByRole("heading", { name: "Base" })).toBeVisible();
31+
await expect(page.getByRole("heading", { name: "Plus" })).toBeVisible();
32+
await page.getByRole("button", { name: "Get Started" }).nth(1).click();
33+
});
3334

34-
await test.step("Verify checkout page for Plus plan", async () => {
35-
await expect(page).toHaveURL(
36-
/.*\/pricing\/checkout\?plan=Plus&amount=1200$/,
37-
);
38-
await expect(
39-
page.getByRole("heading", { name: "Complete Your Purchase" }),
40-
).toBeVisible();
41-
await expect(
42-
page.getByText("You are purchasing: Plus for $12/month"),
43-
).toBeVisible();
44-
});
35+
await test.step("Verify checkout page for Plus plan", async () => {
36+
await expect(page).toHaveURL(
37+
/.*\/pricing\/checkout\?plan=Plus&amount=1200$/,
38+
);
39+
await expect(
40+
page.getByRole("heading", { name: "Complete Your Purchase" }),
41+
).toBeVisible();
42+
await expect(
43+
page.getByText("You are purchasing: Plus for $12/month"),
44+
).toBeVisible();
45+
});
4546

46-
await test.step("Fill payment information", async () => {
47-
await page
48-
.getByRole("textbox", { name: "Card Holder Name" })
49-
.fill("John Doe");
50-
await page
51-
.getByRole("textbox", { name: "Card Number (8 digits only)" })
52-
.fill("12345678");
53-
await page.getByRole("textbox", { name: "Expiry Date" }).fill("12/25");
54-
await page.getByRole("textbox", { name: "CVV" }).fill("123");
55-
});
47+
await test.step("Fill payment information", async () => {
48+
await page
49+
.getByRole("textbox", { name: "Card Holder Name" })
50+
.fill("John Doe");
51+
await page
52+
.getByRole("textbox", { name: "Card Number (8 digits only)" })
53+
.fill("12345678");
54+
await page.getByRole("textbox", { name: "Expiry Date" }).fill("12/25");
55+
await page.getByRole("textbox", { name: "CVV" }).fill("123");
56+
});
5657

57-
await test.step("Fill billing address", async () => {
58-
await page
59-
.getByRole("textbox", { name: "Street Address" })
60-
.fill("123 Main Street");
61-
await page.getByRole("textbox", { name: "City" }).fill("New York");
62-
await page.getByRole("textbox", { name: "State" }).fill("NY");
63-
await page.getByRole("textbox", { name: "ZIP Code" }).fill("10001");
64-
await page
65-
.getByRole("textbox", { name: "Country" })
66-
.fill("United States");
67-
});
58+
await test.step("Fill billing address", async () => {
59+
await page
60+
.getByRole("textbox", { name: "Street Address" })
61+
.fill("123 Main Street");
62+
await page.getByRole("textbox", { name: "City" }).fill("New York");
63+
await page.getByRole("textbox", { name: "State" }).fill("NY");
64+
await page.getByRole("textbox", { name: "ZIP Code" }).fill("10001");
65+
await page
66+
.getByRole("textbox", { name: "Country" })
67+
.fill("United States");
68+
});
6869

69-
await test.step("Complete purchase", async () => {
70-
await page
71-
.getByRole("button", { name: "Complete Purchase - $12/month" })
72-
.click();
73-
});
70+
await test.step("Complete purchase", async () => {
71+
await page
72+
.getByRole("button", { name: "Complete Purchase - $12/month" })
73+
.click();
74+
});
7475

75-
await test.step("Verify successful upgrade to Plus plan", async () => {
76-
await expect(page).toHaveURL(/.*\/dashboard\?payment=success$/);
77-
await expect(
78-
page.getByRole("heading", { name: "Team Settings" }),
79-
).toBeVisible();
80-
await expect(page.getByText("Current Plan: Plus")).toBeVisible();
81-
await expect(page.getByText("Billed monthly")).toBeVisible();
82-
await expect(page.getByText("No active subscription")).not.toBeVisible();
83-
});
84-
});
76+
await test.step("Verify successful upgrade to Plus plan", async () => {
77+
await expect(page).toHaveURL(/.*\/dashboard\?payment=success$/);
78+
await expect(
79+
page.getByRole("heading", { name: "Team Settings" }),
80+
).toBeVisible();
81+
await expect(page.getByText("Current Plan: Plus")).toBeVisible();
82+
await expect(page.getByText("Billed monthly")).toBeVisible();
83+
await expect(
84+
page.getByText("No active subscription"),
85+
).not.toBeVisible();
86+
});
87+
},
88+
);
8589
});

‎tutorial/stage-3-endform-integration/speeding-up-with-endform.mdx‎

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ sidebar:
66
---
77

88
import { Aside } from '@astrojs/starlight/components';
9+
import { Image } from "astro:assets";
10+
import TestTimeChart from "../../../assets/test-time-chart.png";
911

1012
In this guide, we will use endform to speed up your test suite.
1113

@@ -16,3 +18,66 @@ For more information about getting started with the tutorial repository, go [her
1618

1719
At this point in time, we have a pretty decent Playwriht end to end testing suite that can test most of the dummy features in this application.
1820
We can test complex multi user flows like inviting, and we have the ability to create new users on demand when the user data conflicts with other tests.
21+
22+
Since this a very simple application, our tests are thankfully very fast to run. Let's explore their performance.
23+
24+
## Running the tests
25+
26+
We are familiar with running the tests with Playwright:
27+
28+
```bash
29+
pnpm playwright test
30+
```
31+
32+
Let's try running the tests with Endform also to get a benchmark:
33+
34+
```bash
35+
pnpm endform test
36+
```
37+
38+
On my machine (M2 Macbook Pro), the tests ran in 20 seconds with Playwright, and 25 seconds with Endform.
39+
40+
With these very fast, very small, and few tests - uploading and running the tests on Endform's remote runners aren't giving us much of a speedup.
41+
42+
## Cranking up the heat
43+
44+
Let's see what happens when we run more tests.
45+
46+
```bash
47+
pnpm playwright test --repeat-each 2
48+
```
49+
50+
```bash
51+
pnpm endform test --repeat-each 2
52+
```
53+
54+
Here, Playwright took 30 seconds, and Endform took 25 seconds.
55+
56+
```bash
57+
pnpm playwright test --repeat-each 5
58+
```
59+
60+
```bash
61+
pnpm endform test --repeat-each 5
62+
```
63+
64+
Here, Playwright took 30 seconds, and Endform took 25 seconds.
65+
66+
If we plot the results of different repeat counts, we get:
67+
68+
<Image src={TestTimeChart} alt="A chart of the test time for different repeat counts" width={600} />
69+
70+
Once we start to add more tests (or if the tests had taken longer to run), Playwright will keep slowing your suite down,
71+
while Endform will keep the speed constant.
72+
73+
### Other influential factors
74+
75+
This is one case of the speed of this particular suite, but lots of things have an impact on the speed of a suite.
76+
Like:
77+
78+
- How reliable or flaky the tests are
79+
- How long the tests take to run
80+
- How slow the slowest test is
81+
- How performant the app the tests are run against is
82+
83+
We think that we have the fastest Playwright test runner on the market, but we're really curious to hear what your experience in running Endform versus Playwright in your test suite is like.
21.5 KB
Loading

0 commit comments

Comments
 (0)