Skip to content
Merged
28 changes: 28 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Run Tests

on:
pull_request:
branches: [main]
push:
branches: [main]

jobs:
test:
runs-on: ubuntu-latest

steps:
- name: Checkout Code
uses: actions/checkout@v3
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

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

GitHub Actions is using actions/checkout@v3. Consider bumping to actions/checkout@v4 to stay on the currently supported major version and receive the latest fixes.

Suggested change
uses: actions/checkout@v3
uses: actions/checkout@v4

Copilot uses AI. Check for mistakes.

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 22

- name: Install Dependencies
working-directory: ./server
run: npm ci

- name: Run Tests
working-directory: ./server
run: npx vitest run
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ Transfer files across your local network directly from device to device using We
- [2. Install Dependencies](#2-install-dependencies)
- [3. Run the Signaling Server](#3-run-the-signaling-server)
- [4. Serve the Frontend](#4-serve-the-frontend)
- [Running Tests](#running-tests)
- [Self-Hosting](#self-hosting)
- [Frontend — GitHub Pages](#frontend--github-pages)
- [Backend — Signaling Server](#backend--signaling-server)
Expand Down Expand Up @@ -182,6 +183,31 @@ Then open `http://localhost:8080` in your browser.

---

## Running Tests

### Prerequisites

- Node.js 16+ and npm installed
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

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

The new test instructions say Node.js 16+, but the added test toolchain (vitest@4.1.0) declares Node >=20 in the lockfile. Update the README prerequisites to match the minimum Node version actually required to run npm test successfully.

Suggested change
- Node.js 16+ and npm installed
- Node.js 20+ and npm installed

Copilot uses AI. Check for mistakes.
- Server dependencies installed in the `server` folder (`npm install`)

### Commands

From the project root:

```bash
cd server
npx vitest run
```

Or run the npm test script (watch mode):

```bash
cd server
npm test
```
Comment on lines +188 to +207
Copy link

Copilot AI Mar 21, 2026

Choose a reason for hiding this comment

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

README says Node.js 16+ and describes npm test as "watch mode", but server/package.json runs vitest run and the added devDependencies (vitest/vite) require a newer Node version. Please update the Node version requirement and adjust the command descriptions to match the actual scripts (or update scripts to match the docs).

Copilot uses AI. Check for mistakes.
Comment on lines +202 to +207
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

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

README says "Or run the npm test script (watch mode)", but server/package.json defines npm test as vitest run (non-watch, single run). Adjust the wording (or the script) so the described behavior matches what actually runs.

Copilot uses AI. Check for mistakes.

---

## Self-Hosting

### Frontend — GitHub Pages
Expand Down
15 changes: 12 additions & 3 deletions server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,15 @@ wss.on('connection', (ws, req) => {
});

const PORT = process.env.PORT || 3000;
server.listen(PORT, () => {
console.log(`Signaling server running on port ${PORT}`);
});

function startServer(port = PORT) {
return server.listen(port, () => {
console.log(`Signaling server running on port ${port}`);
});
}

if (require.main === module && process.env.NODE_ENV !== 'test') {
startServer();
}

module.exports = { app, server, startServer };
Loading
Loading