testit/test/run.html

35 lines
1.1 KiB
HTML
Raw Normal View History

2018-03-31 22:45:35 +00:00
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<title>Test It Spec</title>
2020-09-08 22:37:24 +00:00
<script src="index.spec.js"></script>
<style>
#summary {font-size: 2rem; text-transform: uppercase;}
</style>
2018-03-31 22:45:35 +00:00
</head>
<body>
2020-09-08 22:37:24 +00:00
<div id="summary"></div>
<div id="errors"></div>
<script type="module">
import test from "../src/testit.js";
test.it(spec(test)).run(false, function(r) {
let errors = [];
document.body.style.backgroundColor = (
r.fail.length ? "#ff9999" : "#99ff99"
);
2018-03-31 22:45:35 +00:00
2020-09-08 22:37:24 +00:00
r.pass.forEach((p) => errors.push(`<br>${p}`));
r.fail.forEach((f) => errors.push(`<br><b>${f}</b>`));
2018-06-06 10:36:42 +00:00
2020-09-08 22:37:24 +00:00
document.querySelector('#errors').innerHTML = errors;
document.querySelector('#summary').innerHTML = `tests: ${r.pass.length + r.fail.length} pass: ${r.pass.length} fail: ${r.fail.length}`;
2018-03-31 22:45:35 +00:00
});
</script>
</body>
</html>