|
9 | 9 | margin: 8px;
|
10 | 10 | }
|
11 | 11 | </style>
|
12 |
| - |
13 | 12 | <script src="../node_modules/mocha/mocha.js"></script>
|
14 | 13 | <script src="../node_modules/expect.js/index.js"></script>
|
15 | 14 | <script src="../node_modules/sinon/pkg/sinon.js"></script>
|
| 15 | + <script src="../resources/benchmark-runner.mjs" type="module"></script> |
| 16 | + </head> |
| 17 | + |
| 18 | + <body> |
| 19 | + <div id="mocha"></div> |
16 | 20 | <script type="module">
|
17 | 21 | mocha.setup({
|
18 | 22 | ui: "bdd",
|
|
22 | 26 | },
|
23 | 27 | },
|
24 | 28 | });
|
25 |
| - </script> |
26 |
| - </head> |
27 | 29 |
|
28 |
| - <body> |
29 |
| - <div id="mocha"></div> |
30 |
| - <script src="../resources/benchmark-runner.mjs" type="module"></script> |
31 |
| - <script src="benchmark-runner-tests.mjs" type="module"></script> |
32 |
| - <script type="module"> |
33 |
| - function startTest() { |
34 |
| - const runner = mocha.run(); |
35 |
| - window.mochaResults = runner; |
| 30 | + await import("./benchmark-runner-tests.mjs"); |
36 | 31 |
|
37 |
| - function createReport(node) { |
38 |
| - const tree = { |
39 |
| - tests: [], |
40 |
| - suites: [], |
41 |
| - id: node.id, |
42 |
| - title: node.title, |
43 |
| - root: node.root, |
44 |
| - }; |
| 32 | + globalThis.testResults = undefined; |
| 33 | + globalThis.testRunner = mocha.run(); |
45 | 34 |
|
46 |
| - for (const test of node.tests) { |
47 |
| - tree.tests.push({ |
48 |
| - id: test.id, |
49 |
| - title: test.title, |
50 |
| - state: test.state, |
51 |
| - error: { |
52 |
| - name: test?.err?.name, |
53 |
| - message: test?.err?.message, |
54 |
| - }, |
55 |
| - }); |
56 |
| - } |
| 35 | + function createReport(node) { |
| 36 | + const tree = { |
| 37 | + tests: [], |
| 38 | + suites: [], |
| 39 | + id: node.id, |
| 40 | + title: node.title, |
| 41 | + root: node.root, |
| 42 | + }; |
57 | 43 |
|
58 |
| - for (const suite of node.suites) { |
59 |
| - tree.suites.push(createReport(suite)); |
60 |
| - } |
| 44 | + for (const test of node.tests) { |
| 45 | + tree.tests.push({ |
| 46 | + id: test.id, |
| 47 | + title: test.title, |
| 48 | + state: test.state, |
| 49 | + error: { |
| 50 | + name: test?.err?.name, |
| 51 | + message: test?.err?.message, |
| 52 | + }, |
| 53 | + }); |
| 54 | + } |
61 | 55 |
|
62 |
| - return tree; |
| 56 | + for (const suite of node.suites) { |
| 57 | + tree.suites.push(createReport(suite)); |
63 | 58 | }
|
64 | 59 |
|
65 |
| - runner.on("end", function () { |
66 |
| - window.suite = createReport(runner.suite); |
67 |
| - window.dispatchEvent(new Event("test-complete")); |
68 |
| - }); |
| 60 | + return tree; |
69 | 61 | }
|
70 | 62 |
|
71 |
| - window.addEventListener("start-test", () => startTest(), { once: true }); |
72 |
| - window.benchmarkReady = true; |
73 |
| - window.dispatchEvent(new Event("benchmark-ready")); |
| 63 | + globalThis.testRunner.on("end", () => { |
| 64 | + globalThis.testResults = createReport(globalThis.testRunner.suite); |
| 65 | + globalThis.dispatchEvent(new Event("test-complete")); |
| 66 | + }); |
74 | 67 | </script>
|
75 | 68 | </body>
|
76 | 69 | </html>
|
0 commit comments