Skip to content
Merged
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
26 changes: 13 additions & 13 deletions .githooks/pre-push
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
#!/bin/sh
# Run signaling server tests before push
# Run all tests before push

echo "Running signaling server tests..."

cd "$(git rev-parse --show-toplevel)/signaling-server" || exit 1
ROOT="$(git rev-parse --show-toplevel)"

# Load nvm so we get Node 24 as pinned in .nvmrc
# Load nvm so we get the Node version pinned in each directory's .nvmrc
export NVM_DIR="${NVM_DIR:-$HOME/.nvm}"
# shellcheck disable=SC1091
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"

# ── Signaling server ──────────────────────────────────────────────────────────
echo "Running signaling server tests..."
cd "$ROOT/signaling-server" || exit 1
nvm use --silent
npm test || { echo "Signaling server tests failed. Push aborted."; exit 1; }

npm test
STATUS=$?

if [ $STATUS -ne 0 ]; then
echo "Tests failed. Push aborted."
exit 1
fi
# ── Client ────────────────────────────────────────────────────────────────────
echo "Running client tests..."
cd "$ROOT/client" || exit 1
nvm use --silent
pnpm test || { echo "Client tests failed. Push aborted."; exit 1; }

echo "Tests passed."
echo "All tests passed."
exit 0
27 changes: 26 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ on:
branches: [main]

jobs:
test:
test-server:
name: Signaling server tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -23,3 +24,27 @@ jobs:
- name: Run tests
run: npm test
working-directory: signaling-server

test-client:
name: Client tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: pnpm/action-setup@v3
with:
version: 8

Comment thread
afraser marked this conversation as resolved.
- uses: actions/setup-node@v4
with:
node-version: 24
cache: pnpm
cache-dependency-path: client/pnpm-lock.yaml

- name: Install dependencies
run: pnpm install --frozen-lockfile
working-directory: client

- name: Run tests
run: pnpm test
working-directory: client
35 changes: 35 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,41 @@ Open **http://localhost:3000** in your browser.

---

## Testing

Both test suites require **Node 24** (pinned via `.nvmrc` in each directory — run `nvm use` if you use nvm).

### Signaling server — integration tests

```bash
cd signaling-server
npm test
```

22 integration tests covering room creation, peer join/leave, host-left notifications, and edge cases. Uses Node's built-in `node:test` runner.

### Client — unit / component tests

```bash
cd client
pnpm test # run once
pnpm test:watch # watch mode
Comment thread
afraser marked this conversation as resolved.
```

44 tests across 5 files:

| File | What it covers |
|------|----------------|
| `src/App.test.jsx` | Route rendering and navigation |
| `src/hooks/useSignaling.test.js` | WebSocket lifecycle, reconnect backoff |
| `src/components/HostView.test.jsx` | Signaling UI states, audio capture errors, WebRTC offer/ICE/answer flow |
| `src/components/PeerView.test.jsx` | Room join UI, auto-join from URL, WebRTC answer/ICE flow |
| `src/components/AudioVisualizer.test.jsx` | AudioContext setup and teardown |

Stack: [Vitest](https://vitest.dev/) + [@testing-library/react](https://testing-library.com/docs/react-testing-library/intro/).

---

## Project Structure

```
Expand Down
15 changes: 12 additions & 3 deletions client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,23 @@
"scripts": {
"dev": "vite",
"build": "vite build",
"preview": "vite preview"
"preview": "vite preview",
"test": "vitest run",
"test:watch": "vitest"
},
"dependencies": {
"react": "^18.2.0",
"react-dom": "^18.2.0"
"react-dom": "^18.2.0",
"react-router-dom": "^7.13.1"
Comment thread
afraser marked this conversation as resolved.
},
"devDependencies": {
"@testing-library/jest-dom": "^6.9.1",
"@testing-library/react": "^16.3.2",
"@testing-library/user-event": "^14.6.1",
"@vitejs/plugin-react": "^4.2.0",
"vite": "^5.0.0"
"jsdom": "^28.1.0",
"mockrtc": "^0.5.0",
"vite": "^5.0.0",
"vitest": "^2.1.9"
}
}
Loading