mirror of https://github.com/n2geoff/testit.git
35 lines
1.1 KiB
HTML
35 lines
1.1 KiB
HTML
<!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>
|
|
<script src="index.spec.js"></script>
|
|
<style>
|
|
#summary {font-size: 2rem; text-transform: uppercase;}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<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"
|
|
);
|
|
|
|
r.pass.forEach((p) => errors.push(`<br>${p}`));
|
|
r.fail.forEach((f) => errors.push(`<br><b>${f}</b>`));
|
|
|
|
document.querySelector('#errors').innerHTML = errors;
|
|
document.querySelector('#summary').innerHTML = `tests: ${r.pass.length + r.fail.length} pass: ${r.pass.length} fail: ${r.fail.length}`;
|
|
});
|
|
</script>
|
|
</body>
|
|
</html>
|