Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,17 @@ jobs:
done
done
done

- name: Install Playwright Browsers
run: npx playwright install --with-deps

- name: Run Playwright E2E Tests
run: npx playwright test --reporter=html

- name: Upload Playwright Report
if: always() # ensures report uploads even if tests fail
uses: actions/upload-artifact@v4
with:
name: playwright-report
path: playwright-report
retention-days: 7
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,9 @@ src/lib/data/firebase-config.js
src/lib/data/config.js
src/lib/data/contents.js
vite.config.js.timestamp*

# Playwright
/test-results/
/playwright-report/
/blob-report/
/playwright/.cache/
35 changes: 35 additions & 0 deletions docs/test/e2e-testing-basics.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Playwright Basics

See the official documentation at http://playwright.dev/docs/intro

Playwright is another testing framework similar to Vitest in some respects but largely different in its end-to-end approach. Playwright has functions called [locators](http://playwright.dev/docs/locators) to locate page elements and more functions called [actions](https://playwright.dev/docs/input) to interact with them.

Although you can locate many items based on text in their content, classes, or css, it is often preferable to give them test ids to refer to. This is done by adding `data-testid="your-test-id"` in their Svelte HTML tag. Then use:

`const myItem = await page.getByTestId("your-test-id");`

You can install the Playwright plugin for VSCode and run individual tests using the "play" symbol appearing next to each test block (note the app itself must already be running locally).
Comment on lines +7 to +11
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Don’t await getByTestId; it returns a Locator, not a Promise
Using await here is incorrect and may confuse readers. Also, capitalize CSS.

-Although you can locate many items based on text in their content, classes, or css, it is often preferable to give them test ids to refer to. This is done by adding `data-testid="your-test-id"` in their Svelte HTML tag. Then use:
+Although you can locate many items based on text in their content, classes, or CSS, it is often preferable to give them test ids to refer to. This is done by adding `data-testid="your-test-id"` in their Svelte HTML tag. Then use:
 
-`const myItem = await page.getByTestId("your-test-id");`
+`const myItem = page.getByTestId("your-test-id");`
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
Although you can locate many items based on text in their content, classes, or css, it is often preferable to give them test ids to refer to. This is done by adding `data-testid="your-test-id"` in their Svelte HTML tag. Then use:
`const myItem = await page.getByTestId("your-test-id");`
You can install the Playwright plugin for VSCode and run individual tests using the "play" symbol appearing next to each test block (note the app itself must already be running locally).
Although you can locate many items based on text in their content, classes, or CSS, it is often preferable to give them test ids to refer to. This is done by adding `data-testid="your-test-id"` in their Svelte HTML tag. Then use:
`const myItem = page.getByTestId("your-test-id");`
🤖 Prompt for AI Agents
In docs/test/e2e-testing-basics.md around lines 7 to 11, the example incorrectly
awaits page.getByTestId (getByTestId returns a Locator, not a Promise) and also
mentions "css" in lowercase; remove the await so the call is used synchronously
(e.g. const myItem = page.getByTestId("your-test-id");) and capitalize "CSS"
where referenced. Ensure the surrounding text and example reflect that
getByTestId returns a Locator and should not be awaited.


- Make sure your test file ends with `.spec.ts` (or .js for JavaScript).
If you're testing `foo.ts`, you'd probably name the test file `foo.spec.ts`.
- Use the `test` function to write an end-to-end test
- Within each test, use `expect` to provide an assertion.

Here's what a test generally looks like:

```js
test('Test Navigation', async ({ page }) => {
await page.goto('http://localhost:5173/');

await page.getByTestId("about-icon").click();
await expect(page.getByTestId("title")).toHaveText("About");
});
```
Comment on lines +20 to +27
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Include the correct import line in the sample and remove the unnecessary await
Docs should show the canonical import from @playwright/test and a minimal, working example.

 ```js
+import { test, expect } from '@playwright/test';
 test('Test Navigation', async ({ page }) => {
     await page.goto('http://localhost:5173/');
 
-    await page.getByTestId("about-icon").click();
+    await page.getByTestId("about-icon").click();
     await expect(page.getByTestId("title")).toHaveText("About");
 });

<details>
<summary>🤖 Prompt for AI Agents</summary>

In docs/test/e2e-testing-basics.md around lines 20 to 27, the sample is missing
the canonical Playwright import and uses an unnecessary await before
page.getByTestId(...).click(); add the import line "import { test, expect } from
'@playwright/test';" at the top of the snippet and remove the extra await before
the .click() call so the snippet is minimal and correct.


</details>

<!-- fingerprinting:phantom:triton:chinchilla -->

<!-- This is an auto-generated comment by CodeRabbit -->


Gotchas:

- Make sure you import `test`, and `expect` from playwright, not from node.test or vitest.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Correct import guidance: import from @playwright/test (not “playwright”)
The proper package is @playwright/test; importing from “playwright” is incorrect for the test API.

--   Make sure you import `test`, and `expect` from playwright, not from node.test or vitest.
+-   Make sure you import `test` and `expect` from `@playwright/test`, not from Node’s test module or Vitest.
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- Make sure you import `test`, and `expect` from playwright, not from node.test or vitest.
- Make sure you import `test` and `expect` from `@playwright/test`, not from Node’s test module or Vitest.
🤖 Prompt for AI Agents
In docs/test/e2e-testing-basics.md around line 31, the guidance currently
suggests importing test and expect from "playwright" (or is ambiguous); update
the text to explicitly instruct developers to import test and expect from
"@playwright/test" (e.g., "import { test, expect } from '@playwright/test'") and
remove or correct any mention of importing from "playwright", "node.test", or
"vitest" so the doc clearly points to the @playwright/test package as the
correct test API source.


# Running Tests

Run `npx playwright test` in a terminal window to run all the tests in the project. Currently, Playwright does not start the local dev app before testing, so that must be done in another thread first (such as `npm run dev`).
Loading