From 02a5bd296bbb875f6d5a07d11d3c881fce017a03 Mon Sep 17 00:00:00 2001 From: Camillo Bruni Date: Mon, 23 Dec 2024 18:38:44 +0100 Subject: [PATCH 1/3] fix runner --- tests/index.html | 62 ++++++++++++++++++++++-------------------------- tests/run.mjs | 34 ++++++++++---------------- 2 files changed, 41 insertions(+), 55 deletions(-) diff --git a/tests/index.html b/tests/index.html index affa77739..5ca4bae01 100644 --- a/tests/index.html +++ b/tests/index.html @@ -30,47 +30,41 @@ diff --git a/tests/run.mjs b/tests/run.mjs index b047015e0..8d3461d09 100644 --- a/tests/run.mjs +++ b/tests/run.mjs @@ -98,32 +98,24 @@ async function test() { try { await driver.get(`http://localhost:${PORT}/tests/index.html`); - await driver.executeAsyncScript((callback) => { - if (window.benchmarkReady) - callback(); - - window.addEventListener("benchmark-ready", () => callback(), { once: true }); - }); - - const result = await driver.executeAsyncScript(function (callback) { - window.addEventListener( - "test-complete", - () => - callback({ - stats: window.mochaResults.stats, - suite: window.suite, - }), - { once: true } - ); - window.dispatchEvent(new Event("start-test")); + const { testResults, stats } = await driver.executeAsyncScript(function (callback) { + const returnResults = () => + callback({ + stats: globalThis.testRunner.stats, + testResults: globalThis.testResults, + }); + if (window.testResults) + returnResults(); + else + window.addEventListener("test-complete", returnResults, { once: true }); }); - printTree(result.suite); + printTree(testResults); console.log("\nChecking for passed tests..."); - assert(result.stats.passes > 0); + assert(stats.passes > 0); console.log("Checking for failed tests..."); - assert(result.stats.failures === 0); + assert(stats.failures === 0); } finally { console.log("\nTests complete!"); driver.quit(); From 4cfee5d5e3196e21b6856bc6c4859894da4bef9d Mon Sep 17 00:00:00 2001 From: Camillo Bruni Date: Mon, 23 Dec 2024 18:51:03 +0100 Subject: [PATCH 2/3] pre-format --- tests/index.html | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/tests/index.html b/tests/index.html index 5ca4bae01..0df0bd3d5 100644 --- a/tests/index.html +++ b/tests/index.html @@ -9,10 +9,14 @@ margin: 8px; } - + + + + +
- - -
- - -