diff --git a/test/common/debugger.js b/test/common/debugger.js index f5a47cbe06ea71..be7b97fba52885 100644 --- a/test/common/debugger.js +++ b/test/common/debugger.js @@ -88,12 +88,12 @@ function startCLI(args, flags = [], spawnOpts = {}, opts = { randomPort: true }) reject(new Error(message)); } + // Capture stack trace here to show where waitFor was called from when it times out. + const timeoutErr = new Error(`Timeout (${TIMEOUT}) while waiting for ${pattern}`); const timer = setTimeout(() => { tearDown(); - reject(new Error([ - `Timeout (${TIMEOUT}) while waiting for ${pattern}`, - `found: ${this.output}`, - ].join('; '))); + timeoutErr.output = this.output; + reject(timeoutErr); }, TIMEOUT); function tearDown() {