[TS] Fix HTML test runner to properly await and fully check result
authorMatt Corallo <git@bluematt.me>
Sat, 15 Jan 2022 05:35:12 +0000 (05:35 +0000)
committerMatt Corallo <git@bluematt.me>
Mon, 17 Jan 2022 04:34:51 +0000 (04:34 +0000)
ts/test/index.html

index 0467f91fb311daff74d66e551da8671676fefb57..3fc55a6d2ef22697d83b9725343cd8de0942ce91 100644 (file)
@@ -8,17 +8,18 @@
 </script>
 <script type="module">
        import { run_tests } from './tests.mjs';
 </script>
 <script type="module">
        import { run_tests } from './tests.mjs';
+       test_runner = run_tests;
        try {
        try {
-               const result = run_tests('../liblightningjs.wasm');
-               if (result) {
+               const result = await run_tests('../liblightningjs.wasm');
+               if (result === true) {
                        document.getElementById("results").innerHTML = "All Tests Passed (note free-time errors may still occurr)!";
                } else {
                        document.getElementById("results").innerHTML = "Some Tests Failed!";
                }
        } catch (e) {
                        document.getElementById("results").innerHTML = "All Tests Passed (note free-time errors may still occurr)!";
                } else {
                        document.getElementById("results").innerHTML = "Some Tests Failed!";
                }
        } catch (e) {
+               console.error(e);
                document.getElementById("results").innerHTML = "Test failed with exception: " + e;
        }
                document.getElementById("results").innerHTML = "Test failed with exception: " + e;
        }
-       test_runner = run_tests;
 </script>
 </body>
 </html>
 </script>
 </body>
 </html>