Skip to content

Commit 4758c3b

Browse files
Copilotdgreif
andcommitted
Address PR feedback: simplify test setup and remove Node 22 from matrix
Co-authored-by: dgreif <[email protected]>
1 parent 4736a6b commit 4758c3b

File tree

7 files changed

+37
-144
lines changed

7 files changed

+37
-144
lines changed

.github/workflows/nodejs.yml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,12 @@ permissions:
55
jobs:
66
build:
77
runs-on: ubuntu-latest
8-
strategy:
9-
matrix:
10-
node-version: [22, 24]
118
steps:
129
- uses: actions/checkout@v4
13-
- name: Use Node.js ${{ matrix.node-version }}
10+
- name: Use Node.js
1411
uses: actions/setup-node@v4
1512
with:
16-
node-version: ${{ matrix.node-version }}
13+
node-version: 24
1714
cache: npm
1815
- run: npm install
1916
- run: npx playwright install chromium

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"prebuild": "npm run clean && npm run compile",
1919
"compile": "tsc",
2020
"build": "rollup -c",
21-
"test": "npm run lint && node test-runner.js",
21+
"test": "npm run lint && ./scripts/test-with-server.sh",
2222
"prepublishOnly": "npm run build",
2323
"postpublish": "npm publish --ignore-scripts --@github:registry='https://npm.pkg.github.com'"
2424
},

scripts/test-with-server.sh

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/bin/bash
2+
3+
# Start the WebSocket server in the background
4+
node -e "
5+
const ws = require('nodejs-websocket');
6+
ws.createServer(function (conn) {
7+
conn.on('text', function (msg) {
8+
if (msg.startsWith('echo:')) {
9+
conn.sendText(msg.replace('echo:', ''));
10+
} else if (msg.startsWith('close:')) {
11+
const code = msg.replace('close:', '');
12+
conn.close(parseInt(code), 'reason');
13+
}
14+
});
15+
conn.on('error', function (error) {
16+
if (error.code !== 'ECONNRESET') throw error;
17+
});
18+
}).listen(7999, () => console.log('WebSocket server ready'));
19+
" &
20+
21+
SERVER_PID=$!
22+
23+
# Wait for server to be ready
24+
sleep 1
25+
26+
# Run vitest
27+
npx vitest run
28+
TEST_EXIT=$?
29+
30+
# Kill the server
31+
kill $SERVER_PID 2>/dev/null
32+
33+
exit $TEST_EXIT

test-runner.js

Lines changed: 0 additions & 95 deletions
This file was deleted.

test/.eslintrc.json

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,6 @@
77
"env": {
88
"browser": true
99
},
10-
"globals": {
11-
"describe": "readonly",
12-
"it": "readonly",
13-
"expect": "readonly"
14-
},
1510
"rules": {
1611
"import/named": "off"
1712
}

test/setup.js

Lines changed: 0 additions & 37 deletions
This file was deleted.

vitest.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export default defineConfig({
1212
},
1313
],
1414
},
15-
include: ['test/**/test.js'],
15+
include: ['test/test*.js'],
1616
testTimeout: 10000,
1717
},
1818
})

0 commit comments

Comments
 (0)