Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
57 changes: 7 additions & 50 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"opener": "^1.5.2",
"picocolors": "^1.0.0",
"sirv": "^2.0.3",
"ws": "^7.3.1"
"ws": "^8.19.0"
},
"devDependencies": {
"@babel/core": "7.26.9",
Expand Down
14 changes: 10 additions & 4 deletions test/viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,13 @@ describe('WebSocket server', function () {
].join('\r\n'));
});

socket.on('close', function () {
server.close(done);
});

let count = 0;
socket.on('data', function (chunk) {
++count;
const expected = Buffer.from([
'HTTP/1.1 101 Switching Protocols',
'Upgrade: websocket',
Expand All @@ -57,14 +63,14 @@ describe('WebSocket server', function () {
''
].join('\r\n'));

expect(chunk.equals(expected)).to.be.true;
// Because data may be received in multiple chunks, only check the first one
if (count === 1) {
expect(chunk.equals(expected)).to.be.true;
}

// Send a WebSocket frame with a reserved opcode (5) to trigger an error
// to be emitted on the server.
socket.write(Buffer.from([0x85, 0x00]));
socket.on('close', function () {
server.close(done);
});
});
})
.catch(done);
Expand Down