mirror of
https://github.com/hanzoai/workbox.git
synced 2026-09-24 17:04:35 +00:00
* Move and rename files to .ts and update imports * Add type definitions * Fix issues with already converted packages
77 lines
2.0 KiB
Plaintext
77 lines
2.0 KiB
Plaintext
<!DOCTYPE html>
|
|
<!--
|
|
Copyright 2019 Google LLC
|
|
|
|
Use of this source code is governed by an MIT-style
|
|
license that can be found in the LICENSE file or at
|
|
https://opensource.org/licenses/MIT.
|
|
-->
|
|
<html>
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<title>Workbox SW Unit Tests</title>
|
|
<style>
|
|
body {
|
|
font: 1em/1.4 sans-serif;
|
|
margin: 1em;
|
|
}
|
|
#success {
|
|
color: hsl(150, 100%, 40%);
|
|
font-size: 1.33em;
|
|
font-weight: bold;
|
|
}
|
|
#errors {
|
|
color: hsl(0, 100%, 40%);
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<h2>Service Worker Test Runner</h2>
|
|
<p>Running tests for the following modules:</p>
|
|
<ul>
|
|
{% block tests %}
|
|
{% for testModule in testModules %}
|
|
<li><code>{{ testModule }}"</code></li>
|
|
{% endfor %}
|
|
{% endblock %}
|
|
</ul>
|
|
<p>Open the console to see progress...</p>
|
|
<p id="success"></p>
|
|
<pre id="errors"></pre>
|
|
|
|
<script type="module">
|
|
import {Workbox} from '/__WORKBOX/buildFile/workbox-window.prod.mjs';
|
|
|
|
(async () => {
|
|
// // Randomize the test URL so every test run forces a new SW install.
|
|
const wb = new Workbox('test-sw-runner.js.njk?v={{ uniqueID() }}');
|
|
|
|
wb.addEventListener('message', (event) => {
|
|
if (event.data && event.data.type === 'MOCHA_RESULTS') {
|
|
self.mochaResults = event.data.payload;
|
|
|
|
if (self.mochaResults.failures === 0) {
|
|
const styles = [
|
|
`color: hsl(150, 100%, 40%)`,
|
|
`font-weight: bold`,
|
|
`font-size: 1.5em`,
|
|
`padding: .25em 0`,
|
|
];
|
|
console.log('%cAll TESTS PASS!', styles.join(';'));
|
|
document.getElementById('success').textContent = 'ALL TESTS PASS!';
|
|
} else {
|
|
const errors = self.mochaResults.reports.map((report) => {
|
|
return `${report.name}\n${report.stack}`;
|
|
}).join('\n\n');
|
|
|
|
document.getElementById('errors').textContent = errors
|
|
}
|
|
}
|
|
});
|
|
|
|
wb.register();
|
|
})();
|
|
</script>
|
|
</body>
|
|
</html>
|