-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest-runner.js
More file actions
27 lines (25 loc) · 824 Bytes
/
test-runner.js
File metadata and controls
27 lines (25 loc) · 824 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
// Copyright 2018 The Emulation-as-a-Service Authors.
// SPDX-License-Identifier: GPL-2.0-or-later
const log = [];
function installProxy(target, name) {
target[name] = new Proxy(target[name], {
apply(target, thisArg, args) {
log.push([name, ...args]);
return Reflect.apply(target, thisArg, args);
}
});
}
for (const name of ["debug", "error", "info", "log", "warn"]) {
installProxy(console, name);
}
export function finish() {
const el = document.getElementById("console");
const expected = el.textContent.trim();
const output = JSON.stringify(log, undefined, 2);
if (expected === output) {
document.body.style.backgroundColor = "green";
} else {
document.body.style.backgroundColor = "red";
el.textContent += output;
}
}