Post pass message based on testData
This commit is contained in:
parent
4e44fa3f60
commit
d7f3fc4173
|
@ -335,15 +335,9 @@ export class Session {
|
||||||
|
|
||||||
this.send({
|
this.send({
|
||||||
event: "terminalOutput",
|
event: "terminalOutput",
|
||||||
|
expectedOutput,
|
||||||
output,
|
output,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (output.includes(TEST_RUN_FINISHED)) {
|
|
||||||
this.send({
|
|
||||||
event: "testRunFinished",
|
|
||||||
expectedOutput
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
this.term.pty.stderr.on("data", (data) => {
|
this.term.pty.stderr.on("data", (data) => {
|
||||||
|
|
|
@ -19,6 +19,44 @@ function showError({ message, data }) {
|
||||||
document.querySelector("html").classList.add("is-clipped");
|
document.querySelector("html").classList.add("is-clipped");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const postTestResults = (testData, expectedOutput) => {
|
||||||
|
const pass = testData.some((output) => output.includes(expectedOutput));
|
||||||
|
|
||||||
|
window.parent.postMessage(
|
||||||
|
{
|
||||||
|
event: "total_test_start",
|
||||||
|
type: "test",
|
||||||
|
},
|
||||||
|
"*"
|
||||||
|
);
|
||||||
|
|
||||||
|
window.parent.postMessage(
|
||||||
|
{
|
||||||
|
$id: 0,
|
||||||
|
codesandbox: true,
|
||||||
|
event: "test_end",
|
||||||
|
test: {
|
||||||
|
blocks: ["Output"],
|
||||||
|
duration: 1,
|
||||||
|
errors: [,],
|
||||||
|
name: `should be ${expectedOutput}.`,
|
||||||
|
path: "",
|
||||||
|
status: pass ? "pass" : "fail",
|
||||||
|
},
|
||||||
|
type: "test",
|
||||||
|
},
|
||||||
|
"*"
|
||||||
|
);
|
||||||
|
|
||||||
|
window.parent.postMessage(
|
||||||
|
{
|
||||||
|
event: "total_test_end",
|
||||||
|
type: "test",
|
||||||
|
},
|
||||||
|
"*"
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
async function main() {
|
async function main() {
|
||||||
let serviceLogBuffers = {};
|
let serviceLogBuffers = {};
|
||||||
let serviceLogLines = {};
|
let serviceLogLines = {};
|
||||||
|
@ -113,61 +151,11 @@ async function main() {
|
||||||
}
|
}
|
||||||
term.write(message.output);
|
term.write(message.output);
|
||||||
testData.push(message.output);
|
testData.push(message.output);
|
||||||
console.log("writing to term");
|
|
||||||
return;
|
if (testData.join("").includes("Test run finished!")) {
|
||||||
case "testRunFinished":
|
postTestResults(testData, message.expectedOutput);
|
||||||
console.log("testRunFinished");
|
testData = [];
|
||||||
console.log(testData);
|
|
||||||
console.log(message.expectedOutput);
|
|
||||||
testData = [];
|
|
||||||
return;
|
|
||||||
case "testTerminalOutput":
|
|
||||||
if (typeof message.output !== "string") {
|
|
||||||
console.error("Unexpected message from server:", message);
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
term.write(message.output);
|
|
||||||
|
|
||||||
const pass =
|
|
||||||
message.output.replace(/\r\n/g, "") == message.expectedOutput;
|
|
||||||
|
|
||||||
window.parent.postMessage(
|
|
||||||
{
|
|
||||||
event: "total_test_start",
|
|
||||||
type: "test",
|
|
||||||
},
|
|
||||||
"*"
|
|
||||||
);
|
|
||||||
|
|
||||||
window.parent.postMessage(
|
|
||||||
{
|
|
||||||
$id: 0,
|
|
||||||
codesandbox: true,
|
|
||||||
event: "test_end",
|
|
||||||
test: {
|
|
||||||
blocks: ["Output"],
|
|
||||||
duration: 1,
|
|
||||||
errors: [
|
|
||||||
`${message.output.replace(/\r\n/g, "")} did not equal ${
|
|
||||||
message.expectedOutput
|
|
||||||
}`,
|
|
||||||
],
|
|
||||||
name: `should be ${message.expectedOutput}.`,
|
|
||||||
path: "",
|
|
||||||
status: pass ? "pass" : "fail",
|
|
||||||
},
|
|
||||||
type: "test",
|
|
||||||
},
|
|
||||||
"*"
|
|
||||||
);
|
|
||||||
|
|
||||||
window.parent.postMessage(
|
|
||||||
{
|
|
||||||
event: "total_test_end",
|
|
||||||
type: "test",
|
|
||||||
},
|
|
||||||
"*"
|
|
||||||
);
|
|
||||||
return;
|
return;
|
||||||
case "lspStopped":
|
case "lspStopped":
|
||||||
if (clientDisposable) {
|
if (clientDisposable) {
|
||||||
|
|
Loading…
Reference in New Issue