[TS] Fix HTML test runner to properly await and fully check result
[ldk-java] / ts / test / index.html
index a100395426218af4753a7872263b6997c33a3fc3..3fc55a6d2ef22697d83b9725343cd8de0942ce91 100644 (file)
@@ -2,13 +2,24 @@
 <html>
 <head></head>
 <body>
+<h1><div id="results">Running LDK-TS Tests...</div></h1>
 <script type="text/javascript">
        var test_runner;
 </script>
 <script type="module">
        import { run_tests } from './tests.mjs';
-       run_tests('../../liblightningjs.wasm');
        test_runner = run_tests;
+       try {
+               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) {
+               console.error(e);
+               document.getElementById("results").innerHTML = "Test failed with exception: " + e;
+       }
 </script>
 </body>
 </html>