From c38945b752be5362b725bf66cc5d03d4a4540703 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hope=20Olaid=C3=A9?= <79100769+hopeolaide@users.noreply.github.com> Date: Thu, 29 Sep 2022 05:15:10 -0400 Subject: [PATCH] test: use async/await in test-debugger-sb-before-load MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/44697 Reviewed-By: Rich Trott Reviewed-By: Tobias Nießen --- .../test-debugger-sb-before-load.js | 53 ++++++++----------- 1 file changed, 21 insertions(+), 32 deletions(-) diff --git a/test/sequential/test-debugger-sb-before-load.js b/test/sequential/test-debugger-sb-before-load.js index 586687800e8e90..e2267156b7420b 100644 --- a/test/sequential/test-debugger-sb-before-load.js +++ b/test/sequential/test-debugger-sb-before-load.js @@ -10,35 +10,24 @@ const assert = require('assert'); const path = require('path'); // Using sb before loading file. -{ - const scriptFullPath = fixtures.path('debugger', 'cjs', 'index.js'); - const script = path.relative(process.cwd(), scriptFullPath); - - const otherScriptFullPath = fixtures.path('debugger', 'cjs', 'other.js'); - const otherScript = path.relative(process.cwd(), otherScriptFullPath); - - const cli = startCLI([script]); - - function onFatal(error) { - cli.quit(); - throw error; - } - - cli.waitForInitialBreak() - .then(() => cli.waitForPrompt()) - .then(() => cli.command('sb("other.js", 2)')) - .then(() => { - assert.match( - cli.output, - /not loaded yet/, - 'warns that the script was not loaded yet'); - }) - .then(() => cli.stepCommand('cont')) - .then(() => { - assert.ok( - cli.output.includes(`break in ${otherScript}:2`), - 'found breakpoint in file that was not loaded yet'); - }) - .then(() => cli.quit()) - .then(null, onFatal); -} + +const scriptFullPath = fixtures.path('debugger', 'cjs', 'index.js'); +const script = path.relative(process.cwd(), scriptFullPath); + +const otherScriptFullPath = fixtures.path('debugger', 'cjs', 'other.js'); +const otherScript = path.relative(process.cwd(), otherScriptFullPath); + +const cli = startCLI([script]); + +(async () => { + await cli.waitForInitialBreak(); + await cli.waitForPrompt(); + await cli.command('sb("other.js", 2)'); + assert.match(cli.output, /not loaded yet/, + 'warns that the script was not loaded yet'); + await cli.stepCommand('cont'); + assert.ok(cli.output.includes(`break in ${otherScript}:2`), + 'found breakpoint in file that was not loaded yet'); +})() +.then(common.mustCall()) +.finally(() => cli.quit());