port konfigurierbar
This commit is contained in:
60
test/WSDriver_ReceiveMsg.test.js
Normal file
60
test/WSDriver_ReceiveMsg.test.js
Normal file
@@ -0,0 +1,60 @@
|
||||
const WebSocket = require('ws');
|
||||
|
||||
const TEST_URL = "wss://localhost:2095";
|
||||
|
||||
describe("WebSocket Verbindung (appRobot_Driver)", () => {
|
||||
|
||||
let ws;
|
||||
|
||||
beforeAll((done) => {
|
||||
// self-signed cert ignorieren (wichtig!)
|
||||
process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";
|
||||
|
||||
ws = new WebSocket(TEST_URL);
|
||||
|
||||
ws.on('open', () => {
|
||||
done();
|
||||
});
|
||||
|
||||
ws.on('error', (err) => {
|
||||
done(err);
|
||||
});
|
||||
});
|
||||
|
||||
afterAll(() => {
|
||||
if (ws) ws.close();
|
||||
});
|
||||
|
||||
test("Ping → sollte Antwort bekommen", (done) => {
|
||||
|
||||
ws.on('message', (data) => {
|
||||
const msg = data.toString();
|
||||
|
||||
try {
|
||||
expect(msg).toBe("Ping");
|
||||
done();
|
||||
} catch (err) {
|
||||
done(err);
|
||||
}
|
||||
});
|
||||
|
||||
ws.send("Ping");
|
||||
});
|
||||
|
||||
test("GCode senden → sollte Antwort liefern", (done) => {
|
||||
|
||||
ws.on('message', (data) => {
|
||||
const msg = data.toString();
|
||||
|
||||
try {
|
||||
expect(msg).toContain("X"); // M114 response enthält Positionsdaten
|
||||
done();
|
||||
} catch (err) {
|
||||
done(err);
|
||||
}
|
||||
});
|
||||
|
||||
ws.send("G1 X10 F100");
|
||||
});
|
||||
|
||||
});
|
||||
Reference in New Issue
Block a user