Use WebSocket for message proxy

This commit is contained in:
hensm
2019-01-12 06:17:28 +00:00
parent 8f6770e8a0
commit 626b8ca75e
8 changed files with 179 additions and 200 deletions

33
test/messageProxy.js Normal file
View File

@@ -0,0 +1,33 @@
"use strict";
// Create socket connection
const socket = new WebSocket("ws://localhost:8080");
window.sendMessage = (message) => {
socket.send(JSON.stringify(message));
}
const reporterMethods = [
"jasmineDone"
, "jasmineStarted"
, "specDone"
, "specStarted"
, "suiteDone"
, "suiteStarted"
];
const customReporter = {};
// Populate reporter methods
for (const method of reporterMethods) {
customReporter[method] = function (result) {
sendMessage({
subject: method
, data: result
});
}
}
socket.addEventListener("open", ev => {
jasmine.getEnv().addReporter(customReporter);
});