| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <meta charset="utf-8" /> | |
| <title>In-Browser Tests for Speedometer</title> | |
| <link rel="stylesheet" href="../node_modules/mocha/mocha.css" /> | |
| <style> | |
| body { | |
| margin: 8px; | |
| } | |
| </style> | |
| <script src="../node_modules/mocha/mocha.js"></script> | |
| <script src="../node_modules/expect.js/index.js"></script> | |
| <script src="../node_modules/sinon/pkg/sinon.js"></script> | |
| <script src="../resources/benchmark-runner.mjs" type="module"></script> | |
| </head> | |
| <body> | |
| <div id="mocha"></div> | |
| <script type="module"> | |
| mocha.setup({ | |
| ui: "bdd", | |
| rootHooks: { | |
| afterEach() { | |
| sinon.restore(); | |
| }, | |
| }, | |
| }); | |
| await import("./unittests/benchmark-runner.mjs"); | |
| globalThis.testResults = undefined; | |
| globalThis.testRunner = mocha.run(); | |
| function createReport(node) { | |
| const tree = { | |
| tests: [], | |
| suites: [], | |
| id: node.id, | |
| title: node.title, | |
| root: node.root, | |
| }; | |
| for (const test of node.tests) { | |
| tree.tests.push({ | |
| id: test.id, | |
| title: test.title, | |
| state: test.state, | |
| error: { | |
| name: test?.err?.name, | |
| message: test?.err?.message, | |
| }, | |
| }); | |
| } | |
| for (const suite of node.suites) { | |
| tree.suites.push(createReport(suite)); | |
| } | |
| return tree; | |
| } | |
| globalThis.testRunner.on("end", () => { | |
| globalThis.testResults = createReport(globalThis.testRunner.suite); | |
| globalThis.dispatchEvent(new Event("test-complete")); | |
| }); | |
| </script> | |
| </body> | |
| </html> |