Reinstate ws WebSocket library
All checks were successful
Node.js CI / build (18.x) (push) Successful in 16m17s
Node.js CI / build (20.x) (push) Successful in 11s
Node.js CI / build (22.x) (push) Successful in 11s

In some environments, such as MagicMirror modules, the WebSocket class is not defined. This is apparently a client-only class and generally only exists in browsers, but I'm confused how the unit tests were passing when run against just node. Either way, this means we have to disable the test again since ws is not compatible with jest-websocket-mock, and I haven't found an alternative mock server that is.
This commit is contained in:
2025-01-25 12:06:01 -06:00
parent 829a90dd0e
commit 458048b58a
9 changed files with 126 additions and 59 deletions

View File

@ -1,6 +1,7 @@
import { Unit } from "../src/index";
import * as messages from "../src/messages/messages";
import WS from "jest-websocket-mock";
import { Unit } from "../src/index.js";
import * as messages from "../src/messages/messages.js";
import * as WS from "jest-websocket-mock";
import { xdescribe, beforeEach, afterEach, it } from "@jest/globals";
function makeid(length: number) {
const characters =
@ -17,20 +18,21 @@ function makeid(length: number) {
return result;
}
describe("basic message tests", () => {
// temporarily disabled: as long as Unit uses the "ws" library, it is incompatible with the jest-websocket-mock server
xdescribe("basic message tests", () => {
let unit: Unit;
let mockServer: WS;
let mockServer: WS.WS;
beforeEach(async () => {
mockServer = new WS("ws://localhost:6680");
mockServer = new WS.WS("ws://localhost:6680");
unit = new Unit("localhost", 6680);
await unit.connect();
await mockServer.connected;
});
afterEach(async () => {
afterEach(() => {
unit.close();
WS.clean();
WS.WS.clean();
});
it("can send a message and return its response", async () => {