Skip to content

Commit

Permalink
test: add e2e
Browse files Browse the repository at this point in the history
  • Loading branch information
hi-ogawa committed Sep 29, 2024
1 parent d1378de commit fb64f2f
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 12 deletions.
14 changes: 12 additions & 2 deletions examples/web-worker/e2e/basic.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { expect, test } from "@playwright/test";

test("basic", async ({ page }) => {
await page.goto("/");
await expect(page.getByTestId("worker-message")).toContainText(
await expect(page.getByTestId("worker")).toContainText(
"Rendered in web worker",
);
});
Expand All @@ -19,7 +19,17 @@ test("erorr stack", async ({ page }) => {

test("worker in worker", async ({ page }) => {
await page.goto("/?worker-in-worker");
await expect(page.getByTestId("worker-message")).toContainText(
await expect(page.getByTestId("worker")).toContainText(
"Rendered in web worker in web worker",
);
});

test("condition", async ({ page }) => {
await page.goto("/");
await expect(page.getByTestId("client")).toContainText(
"test-dep-conditions: index.browser.js",
);
await expect(page.getByTestId("worker")).toContainText(
"test-dep-conditions: index.worker.js",
);
});
21 changes: 11 additions & 10 deletions examples/web-worker/src/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,18 @@ export function App() {

return (
<div>
<h4>Client</h4>
<div>Count: {count}</div>
<button onClick={() => setCount((c) => c - 1)}>-1</button>
<button onClick={() => setCount((c) => c + 1)}>+1</button>
<div>test-dep-conditions: {depCondition}</div>
<div data-testid="client">
<h4>Client</h4>
<div>Count: {count}</div>
<button onClick={() => setCount((c) => c - 1)}>-1</button>
<button onClick={() => setCount((c) => c + 1)}>+1</button>
<div>test-dep-conditions: {depCondition}</div>
</div>
<hr />
<h4>Worker</h4>
<div
data-testid="worker-message"
dangerouslySetInnerHTML={{ __html: workerMessage }}
></div>
<div data-testid="worker">
<h4>Worker</h4>
<div dangerouslySetInnerHTML={{ __html: workerMessage }} />
</div>
</div>
);
}

0 comments on commit fb64f2f

Please sign in to comment.