You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: TESTING.md
+23-11Lines changed: 23 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,41 +3,48 @@
3
3
This project uses a robust testing pipeline combining Vitest and Playwright to ensure the `GameBoy` component and site functionality work flawlessly across browsers.
4
4
5
5
## 1. Unit Testing (Vitest)
6
+
6
7
Unit tests focus on isolated logic and utility functions that don't depend on browser rendering.
7
8
8
-
***Location:**`tests/unit/`
9
-
***Config:**`vitest.config.ts`
10
-
***Command:**`npm run test:unit`
9
+
-**Location:**`tests/unit/`
10
+
-**Config:**`vitest.config.ts`
11
+
-**Command:**`npm run test:unit`
11
12
12
13
## 2. End-to-End Testing (Playwright)
14
+
13
15
E2E tests simulate real user interactions in a browser environment. The suite covers 100% of the interactive features of the device.
14
16
15
-
***Location:**`tests/e2e/gameboy.spec.ts`
16
-
***Config:**`playwright.config.ts`
17
-
***Command:**`npm run test:e2e`
17
+
-**Location:**`tests/e2e/gameboy.spec.ts`
18
+
-**Config:**`playwright.config.ts`
19
+
-**Command:**`npm run test:e2e`
18
20
19
21
### Test Coverage
22
+
20
23
The E2E suite verifies the following user stories:
24
+
21
25
1.**Boot Sequence**: Ensures the start overlay appears and is dismissible via keyboard interaction.
22
26
2.**Navigation**:
23
-
***D-Pad**: Verifies Up/Down navigation correctly updates active links.
24
-
***Tabs**: Verifies Left/Right navigation switches between Links, About, and Help tabs.
27
+
-**D-Pad**: Verifies Up/Down navigation correctly updates active links.
28
+
-**Tabs**: Verifies Left/Right navigation switches between Links, About, and Help tabs.
25
29
3.**Selection**: Validates that pressing 'Enter' (A button) triggers link navigation.
26
30
4.**Theming**: Checks that switching themes (B button) updates the DOM and persists across page reloads (via `localStorage`).
27
31
5.**Audio**: Confirms toggling mute (M key) updates state and persists across reloads.
28
32
6.**Hardware Features**:
29
-
***Power Switch**: Verifies the power switch toggles the console on/off.
30
-
***Konami Code**: Inputs the secret code (Up, Up, Down, Down, Left, Right, Left, Right, B, A) and verifies the "Matrix Mode" visual effect.
33
+
-**Power Switch**: Verifies the power switch toggles the console on/off.
34
+
-**Konami Code**: Inputs the secret code (Up, Up, Down, Down, Left, Right, Left, Right, B, A) and verifies the "Matrix Mode" visual effect.
31
35
32
36
## 3. Static Analysis
37
+
33
38
Validates `.astro` file syntax and TypeScript types.
34
39
35
-
***Command:**`npm run check` (runs `astro check`)
40
+
-**Command:**`npm run check` (runs `astro check`)
36
41
37
42
## CI/CD Pipeline
43
+
38
44
A GitHub Actions workflow (`.github/workflows/ci.yml`) runs on every push to `main` and pull requests.
39
45
40
46
**Workflow Steps:**
47
+
41
48
1.**Install**: Sets up Node.js and dependencies.
42
49
2.**Check**: Runs static analysis.
43
50
3.**Unit Tests**: Executes Vitest suite.
@@ -46,6 +53,7 @@ A GitHub Actions workflow (`.github/workflows/ci.yml`) runs on every push to `ma
46
53
6.**Artifacts**: Uploads failure traces and videos if tests fail.
47
54
48
55
## Pre-Push Hooks (Husky)
56
+
49
57
To catch errors before they event reach the CI pipeline, this project uses [Husky](https://typicode.github.io/husky/) to enforce local testing before pushing code to the remote repository.
50
58
51
59
A `pre-push` hook is configured (in `.husky/pre-push`) to automatically run `npm run test` (which triggers both Unit Tests and E2E Tests) whenever `git push` is invoked locally. If any tests fail, the push is aborted.
@@ -55,13 +63,17 @@ This prevents the codebase from bloated `pre-commit` times, while guaranteeing t
55
63
## Debugging
56
64
57
65
### Interactive Mode (UI)
66
+
58
67
To debug tests visually, use the Playwright UI mode. This allows you to step through tests, time-travel, and inspect the DOM.
0 commit comments