Skip to content

Commit 28b57e4

Browse files
committed
test: capture stack trace in debugger timeout errors
Otherwise when the expected prompt does not show up in the session and the debugger tests time out, there is not enough information to figure out exactly which line in the test is causing the timeout.
1 parent 3c8c1ef commit 28b57e4

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

test/common/debugger.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,12 +88,14 @@ function startCLI(args, flags = [], spawnOpts = {}, opts = { randomPort: true })
8888
reject(new Error(message));
8989
}
9090

91+
// Capture stack trace here to show where waitFor was called from when
92+
// it times out.
93+
const timeoutErr = new Error(`Timeout (${TIMEOUT}) while waiting for ${pattern}`);
94+
Error.captureStackTrace(timeoutErr, this.waitFor);
9195
const timer = setTimeout(() => {
9296
tearDown();
93-
reject(new Error([
94-
`Timeout (${TIMEOUT}) while waiting for ${pattern}`,
95-
`found: ${this.output}`,
96-
].join('; ')));
97+
err.output = this.output;
98+
reject(err);
9799
}, TIMEOUT);
98100

99101
function tearDown() {

0 commit comments

Comments
 (0)