diff --git a/test/cli/backtrace.test.js b/test/cli/backtrace.test.js index 9cd8a82..127ea56 100644 --- a/test/cli/backtrace.test.js +++ b/test/cli/backtrace.test.js @@ -14,7 +14,7 @@ test('display and navigate backtrace', (t) => { throw error; } - return cli.waitFor(/break/) + return cli.waitForInitialBreak() .then(() => cli.waitForPrompt()) .then(() => cli.stepCommand('c')) .then(() => cli.command('bt')) diff --git a/test/cli/break.test.js b/test/cli/break.test.js index 1c662d6..5de3e52 100644 --- a/test/cli/break.test.js +++ b/test/cli/break.test.js @@ -14,12 +14,12 @@ test('stepping through breakpoints', (t) => { throw error; } - return cli.waitFor(/break/) + return cli.waitForInitialBreak() .then(() => cli.waitForPrompt()) .then(() => { t.match( cli.output, - `break in ${script}:1`, + ` in ${script}:1`, 'pauses in the first line of the script'); t.match( cli.output, @@ -30,7 +30,7 @@ test('stepping through breakpoints', (t) => { .then(() => { t.match( cli.output, - `break in ${script}:2`, + ` in ${script}:2`, 'pauses in next line of the script'); t.match( cli.output, @@ -41,7 +41,7 @@ test('stepping through breakpoints', (t) => { .then(() => { t.match( cli.output, - `break in ${script}:3`, + ` in ${script}:3`, 'pauses in next line of the script'); t.match( cli.output, @@ -52,7 +52,7 @@ test('stepping through breakpoints', (t) => { .then(() => { t.match( cli.output, - `break in ${script}:10`, + ` in ${script}:10`, 'pauses on the next breakpoint'); t.match( cli.output, @@ -94,21 +94,21 @@ test('stepping through breakpoints', (t) => { .then(() => { t.match( cli.output, - 'break in timers.js', + ' in timers.js', 'entered timers.js'); }) .then(() => cli.stepCommand('cont')) .then(() => { t.match( cli.output, - `break in ${script}:16`, + ` in ${script}:16`, 'found breakpoint we set above w/ line number only'); }) .then(() => cli.stepCommand('cont')) .then(() => { t.match( cli.output, - `break in ${script}:6`, + ` in ${script}:6`, 'found breakpoint we set above w/ line number & script'); }) .then(() => cli.stepCommand('')) @@ -132,7 +132,7 @@ test('sb before loading file', (t) => { throw error; } - return cli.waitFor(/break/) + return cli.waitForInitialBreak() .then(() => cli.waitForPrompt()) .then(() => cli.command('sb("other.js", 3)')) .then(() => { @@ -145,7 +145,7 @@ test('sb before loading file', (t) => { .then(() => { t.match( cli.output, - `break in ${otherScript}:3`, + ` in ${otherScript}:3`, 'found breakpoint in file that was not loaded yet'); }) .then(() => cli.quit()) @@ -161,7 +161,7 @@ test('clearBreakpoint', (t) => { throw error; } - return cli.waitFor(/break/) + return cli.waitForInitialBreak() .then(() => cli.waitForPrompt()) .then(() => cli.command('sb("break.js", 3)')) .then(() => cli.command('sb("break.js", 9)')) @@ -187,7 +187,7 @@ test('clearBreakpoint', (t) => { .then(() => { t.match( cli.output, - `break in ${script}:9`, + ` in ${script}:9`, 'hits the 2nd breakpoint because the 1st was cleared'); }) .then(() => cli.quit()) diff --git a/test/cli/exceptions.test.js b/test/cli/exceptions.test.js index b66c09f..5a9f814 100644 --- a/test/cli/exceptions.test.js +++ b/test/cli/exceptions.test.js @@ -14,10 +14,10 @@ test('break on (uncaught) exceptions', (t) => { throw error; } - return cli.waitFor(/break/) + return cli.waitForInitialBreak() .then(() => cli.waitForPrompt()) .then(() => { - t.match(cli.output, `break in ${script}:1`); + t.match(cli.output, ` in ${script}:1`); }) // making sure it will die by default: .then(() => cli.command('c')) @@ -26,7 +26,7 @@ test('break on (uncaught) exceptions', (t) => { // Next run: With `breakOnException` it pauses in both places .then(() => cli.stepCommand('r')) .then(() => { - t.match(cli.output, `break in ${script}:1`); + t.match(cli.output, ` in ${script}:1`); }) .then(() => cli.command('breakOnException')) .then(() => cli.stepCommand('c')) @@ -42,7 +42,7 @@ test('break on (uncaught) exceptions', (t) => { .then(() => cli.command('breakOnUncaught')) .then(() => cli.stepCommand('r')) // also, the setting survives the restart .then(() => { - t.match(cli.output, `break in ${script}:1`); + t.match(cli.output, ` in ${script}:1`); }) .then(() => cli.stepCommand('c')) .then(() => { @@ -53,7 +53,7 @@ test('break on (uncaught) exceptions', (t) => { .then(() => cli.command('breakOnNone')) .then(() => cli.stepCommand('r')) .then(() => { - t.match(cli.output, `break in ${script}:1`); + t.match(cli.output, ` in ${script}:1`); }) .then(() => cli.command('c')) .then(() => cli.waitFor(/disconnect/)) diff --git a/test/cli/exec.test.js b/test/cli/exec.test.js index 5c64713..acfd6e3 100644 --- a/test/cli/exec.test.js +++ b/test/cli/exec.test.js @@ -11,7 +11,7 @@ test('examples/alive.js', (t) => { throw error; } - return cli.waitFor(/break/) + return cli.waitForInitialBreak() .then(() => cli.waitForPrompt()) .then(() => cli.command('exec [typeof heartbeat, typeof process.exit]')) .then(() => { @@ -60,7 +60,7 @@ test('exec .scope', (t) => { throw error; } - return cli.waitFor(/break/) + return cli.waitForInitialBreak() .then(() => cli.waitForPrompt()) .then(() => cli.stepCommand('c')) .then(() => cli.command('exec .scope')) diff --git a/test/cli/help.test.js b/test/cli/help.test.js index 11a9358..9f0c081 100644 --- a/test/cli/help.test.js +++ b/test/cli/help.test.js @@ -11,7 +11,7 @@ test('examples/empty.js', (t) => { throw error; } - return cli.waitFor(/break/) + return cli.waitForInitialBreak() .then(() => cli.waitForPrompt()) .then(() => cli.command('help')) .then(() => { diff --git a/test/cli/launch.test.js b/test/cli/launch.test.js index 99c6ce0..0af27b1 100644 --- a/test/cli/launch.test.js +++ b/test/cli/launch.test.js @@ -9,7 +9,7 @@ test('examples/empty.js', (t) => { const script = Path.join('examples', 'empty.js'); const cli = startCLI([script]); - return cli.waitFor(/break/) + return cli.waitForInitialBreak() .then(() => cli.waitForPrompt()) .then(() => { t.match(cli.output, 'debug>', 'prints a prompt'); @@ -45,7 +45,7 @@ test('run after quit / restart', (t) => { throw error; } - return cli.waitFor(/break/) + return cli.waitForInitialBreak() .then(() => cli.waitForPrompt()) .then(() => cli.stepCommand('n')) .then(() => { diff --git a/test/cli/low-level.test.js b/test/cli/low-level.test.js index b6301b2..966bed5 100644 --- a/test/cli/low-level.test.js +++ b/test/cli/low-level.test.js @@ -12,7 +12,7 @@ test('Debugger agent direct access', (t) => { throw error; } - return cli.waitFor(/break/) + return cli.waitForInitialBreak() .then(() => cli.waitForPrompt()) .then(() => cli.command('scripts')) .then(() => { diff --git a/test/cli/preserve-breaks.test.js b/test/cli/preserve-breaks.test.js index 8de8227..17d7976 100644 --- a/test/cli/preserve-breaks.test.js +++ b/test/cli/preserve-breaks.test.js @@ -14,7 +14,7 @@ test('run after quit / restart', (t) => { throw error; } - return cli.waitFor(/break/) + return cli.waitForInitialBreak() .then(() => cli.waitForPrompt()) .then(() => cli.command('breakpoints')) .then(() => { diff --git a/test/cli/profile.test.js b/test/cli/profile.test.js index 3ef1896..0f900c5 100644 --- a/test/cli/profile.test.js +++ b/test/cli/profile.test.js @@ -15,7 +15,7 @@ test('profiles', (t) => { throw error; } - return cli.waitFor(/break/) + return cli.waitForInitialBreak() .then(() => cli.waitForPrompt()) .then(() => cli.command('exec console.profile()')) .then(() => { diff --git a/test/cli/scripts.test.js b/test/cli/scripts.test.js index cd26411..ed36705 100644 --- a/test/cli/scripts.test.js +++ b/test/cli/scripts.test.js @@ -14,7 +14,7 @@ test('list scripts', (t) => { throw error; } - return cli.waitFor(/break/) + return cli.waitForInitialBreak() .then(() => cli.waitForPrompt()) .then(() => cli.command('scripts')) .then(() => { diff --git a/test/cli/start-cli.js b/test/cli/start-cli.js index 5a652e3..74c9481 100644 --- a/test/cli/start-cli.js +++ b/test/cli/start-cli.js @@ -93,6 +93,10 @@ function startCLI(args) { return this.waitFor(/>\s+$/, timeout); }, + waitForInitialBreak(timeout = 2000) { + return this.waitFor(/break/i, timeout); + }, + ctrlC() { return this.command('.interrupt'); }, diff --git a/test/cli/use-strict.test.js b/test/cli/use-strict.test.js index 81f4d91..780802a 100644 --- a/test/cli/use-strict.test.js +++ b/test/cli/use-strict.test.js @@ -14,7 +14,7 @@ test('for whiles that starts with strict directive', (t) => { throw error; } - return cli.waitFor(/break/) + return cli.waitForInitialBreak() .then(() => cli.waitForPrompt()) .then(() => { t.match( diff --git a/test/cli/watchers.test.js b/test/cli/watchers.test.js index d66f008..46bcde1 100644 --- a/test/cli/watchers.test.js +++ b/test/cli/watchers.test.js @@ -11,7 +11,7 @@ test('stepping through breakpoints', (t) => { throw error; } - return cli.waitFor(/break/) + return cli.waitForInitialBreak() .then(() => cli.waitForPrompt()) .then(() => cli.command('watch("x")')) .then(() => cli.command('watch("\\"Hello\\"")'))