Skip to content

Commit

Permalink
✅ 🚧 Add basic interaction test before structuring app for E2E testing #8
Browse files Browse the repository at this point in the history


Without proper test ids or deeper react integration, the appearance of elements can not be properly awaited. And is also thrown of runtime react errors that do not break behavior.
  • Loading branch information
D1no committed Apr 10, 2023
1 parent 673c29c commit 7a5affa
Showing 1 changed file with 33 additions and 1 deletion.
34 changes: 33 additions & 1 deletion features/spec/sample.spec.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,42 @@
import { expect, test } from "@playwright/test";

test.describe("Sample Browser App", () => {
test.describe("Sample Content", () => {
test("has title", async ({ page }) => {
await page.goto("/");

// Expect a title "to contain" a substring.
await expect(page).toHaveTitle(/Sample App/);
});

test("welcomes user", async ({ page }) => {
await page.goto("/");

// Expect a title "to contain" a substring.
expect(await page.innerText("h1")).toContain("Welcome");
});
});

test.describe("Sample Interaction", () => {
test("can start and stop rating", async ({ page }) => {
await page.goto("/");

await page.getByRole("button", { name: "START" }).click();

expect(await page.getByText("Current Rating: 1")).toBeVisible();

await page.getByRole("button", { name: "STOP" }).click();
});

test("count to 6", async ({ page }) => {
await page.goto("/");

await page.getByRole("button", { name: "START" }).click();

await page.getByRole("button", { name: "+" }).click();
await page.getByRole("button", { name: "+" }).click();
await page.getByRole("button", { name: "+" }).click();
await page.getByRole("button", { name: "+" }).click();
await page.getByRole("button", { name: "+" }).click();

});
});

0 comments on commit 7a5affa

Please sign in to comment.