log-rune
Simon Holthausen 10 months ago
parent ae3ef2c0cf
commit 5205bac9d1

@ -837,7 +837,7 @@ function attach_trace(signal) {
// Chromium-based browsers don't do source mapping based on whether an Error object is handed to them, // Chromium-based browsers don't do source mapping based on whether an Error object is handed to them,
// they purely do pattern matching on the stack trace string. This leads us to unfortunately needing to // they purely do pattern matching on the stack trace string. This leads us to unfortunately needing to
// have "Error" as part of the name even if it's not really one. // have "Error" as part of the name even if it's not really one.
error.stack = `ExpectedError: ($log.trace)\n${error.stack?.split('\n')?.at(3)}`; error.stack = `ExpectedError: $log.trace\n${error.stack?.split('\n')?.at(3)}`;
} else { } else {
// For once, Safari and Firefox do it better // For once, Safari and Firefox do it better
error.name = '$log.trace'; error.name = '$log.trace';

@ -82,7 +82,7 @@ export type SourceSignal<V = unknown> = {
export type SourceSignalDebug = { export type SourceSignalDebug = {
/** debug: This is DEV only */ /** debug: This is DEV only */
d: null | string; d: null | Error;
}; };
export type ComputationSignal<V = unknown> = { export type ComputationSignal<V = unknown> = {

@ -23,14 +23,18 @@ export default test({
after_test() { after_test() {
console.log = original_log; console.log = original_log;
}, },
async test({ assert, target, component }) { async test({ assert, target }) {
const [b1, b2] = target.querySelectorAll('button'); const [b1, b2] = target.querySelectorAll('button');
b1.click(); b1.click();
b2.click(); b2.click();
await Promise.resolve(); await Promise.resolve();
assert.deepEqual(log[0], 0); assert.deepEqual(log[0], 0);
assert.deepEqual(log[1].startsWith('$log.trace: HTMLButtonElement.on_click'), true); assert.deepEqual(
log[1].stack.startsWith('ExpectedError: $log.trace') &&
log[1].stack.includes('HTMLButtonElement.on_click'),
true
);
assert.deepEqual(log[2], 1); assert.deepEqual(log[2], 1);
} }
}); });

Loading…
Cancel
Save