Skip to content

Commit 0947b90

Browse files
committed
Make puter.js tests print out error results
1 parent 37d09a6 commit 0947b90

File tree

1 file changed

+30
-7
lines changed

1 file changed

+30
-7
lines changed

src/puter-js/test/run.html

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,22 @@
4242
// $('#tests').append(`<p style="color:green;">${msg}</p>`);
4343
}
4444

45-
window.fail = function(msg) {
46-
throw new Error(msg);
45+
window.fail = function(msg, error) {
46+
// Include the full error information in the thrown error
47+
let fullMessage = msg;
48+
if (error) {
49+
if (typeof error === 'string') {
50+
fullMessage += ' ' + error;
51+
} else if (error.message) {
52+
fullMessage += ' ' + error.message;
53+
} else {
54+
fullMessage += ' ' + JSON.stringify(error);
55+
}
56+
}
57+
const err = new Error(fullMessage);
58+
// Attach the original error for detailed display
59+
err.originalError = error;
60+
throw err;
4761
}
4862

4963
// print the test name with checkbox for each test
@@ -79,11 +93,15 @@
7993
$(`#fsTests-container-${i}`).css('background-color', '#85e085');
8094

8195
} catch (e) {
82-
console.log(e);
96+
console.error('FS Test failed:', fsTests[i].name, e);
8397
// make this test's container red
8498
$(`#fsTests-container-${i}`).css('background-color', '#ffbfbf');
85-
// message
86-
$(`#fsTests-container-${i}`).append(`<p style="color:#c00000;">${e}</p>`);
99+
// message - show full error information including JSON details
100+
let errorMessage = e.message || e.toString();
101+
if (e.originalError) {
102+
errorMessage += '\n\nOriginal Error:\n' + JSON.stringify(e.originalError, null, 2);
103+
}
104+
$(`#fsTests-container-${i}`).append(`<pre style="color:#c00000; white-space: pre-wrap; font-size: 12px; margin: 5px 0; padding: 10px; background-color: #f8f8f8; border-radius: 3px;">${errorMessage}</pre>`);
87105
}
88106
}
89107
}
@@ -96,10 +114,15 @@
96114
$(`#kvTests-container-${i}`).css('background-color', '#85e085');
97115

98116
} catch (e) {
117+
console.error('KV Test failed:', kvTests[i].name, e);
99118
// make this test's container red
100119
$(`#kvTests-container-${i}`).css('background-color', '#ff8484');
101-
// message
102-
$(`#kvTests-container-${i}`).append(`<p style="color:red;">${e}</p>`);
120+
// message - show full error information including JSON details
121+
let errorMessage = e.message || e.toString();
122+
if (e.originalError) {
123+
errorMessage += '\n\nOriginal Error:\n' + JSON.stringify(e.originalError, null, 2);
124+
}
125+
$(`#kvTests-container-${i}`).append(`<pre style="color:red; white-space: pre-wrap; font-size: 12px; margin: 5px 0; padding: 10px; background-color: #f8f8f8; border-radius: 3px;">${errorMessage}</pre>`);
103126
}
104127
}
105128
}

0 commit comments

Comments
 (0)