fork-openpgpjs/test/unittests.html
Daniel Huigens 01be7b7ec1
CI: Switch to karma for browser tests (#1233)
This should fix the false positives (failures to detect errors).
2021-02-12 13:29:04 +01:00

42 lines
1.3 KiB
HTML

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>OpenPGPJS Unit Tests</title>
<link rel="stylesheet" href="../node_modules/mocha/mocha.css" />
<!-- libs -->
<script src="../node_modules/mocha/mocha.js"></script>
<script>
mocha.setup('bdd');
mocha.timeout(240000);
</script>
</head>
<body>
<div id="mocha"></div>
<script type="module">
import './lib/unittests-bundle.js';
if (typeof openpgp !== 'undefined') {
const runner = mocha.run();
var wasScrolledDown = true;
function beforeTestReport() {
wasScrolledDown = document.documentElement.scrollHeight - document.documentElement.scrollTop - document.documentElement.clientHeight < 50;
}
function afterTestReport() {
if (wasScrolledDown || openpgp.config.ci) {
window.scrollTo(0, document.documentElement.scrollHeight);
}
}
runner._events['suite'].unshift(beforeTestReport);
runner._events['pass'].unshift(beforeTestReport);
runner._events['fail'].unshift(beforeTestReport);
runner._events['pending'].unshift(beforeTestReport);
document.addEventListener('scroll', beforeTestReport);
runner.on('suite', afterTestReport);
runner.on('test end', afterTestReport);
}
</script>
</body>
</html>