From 8033ad846b86f4e8d4830f42ef5a5d607d49d000 Mon Sep 17 00:00:00 2001 From: mmeenapriya <42589859+mmeenapriya@users.noreply.github.com> Date: Thu, 29 Sep 2022 16:32:34 -0500 Subject: [PATCH] test: update test-debugger-scripts to use await/async PR-URL: https://github.com/nodejs/node/pull/44692 Reviewed-By: Rich Trott --- test/sequential/test-debugger-scripts.js | 25 ++++++++++-------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/test/sequential/test-debugger-scripts.js b/test/sequential/test-debugger-scripts.js index c6d4e67920921d..b0f611bd1c6491 100644 --- a/test/sequential/test-debugger-scripts.js +++ b/test/sequential/test-debugger-scripts.js @@ -13,15 +13,11 @@ const assert = require('assert'); const script = fixtures.path('debugger', 'three-lines.js'); const cli = startCLI([script]); - function onFatal(error) { - cli.quit(); - throw error; - } - - return cli.waitForInitialBreak() - .then(() => cli.waitForPrompt()) - .then(() => cli.command('scripts')) - .then(() => { + (async () => { + try { + await cli.waitForInitialBreak(); + await cli.waitForPrompt(); + await cli.command('scripts'); assert.match( cli.output, /^\* \d+: \S+debugger(?:\/|\\)three-lines\.js/m, @@ -30,9 +26,7 @@ const assert = require('assert'); cli.output, /\d+: node:internal\/buffer/, 'omits node-internal scripts'); - }) - .then(() => cli.command('scripts(true)')) - .then(() => { + await cli.command('scripts(true)'); assert.match( cli.output, /\* \d+: \S+debugger(?:\/|\\)three-lines\.js/, @@ -41,7 +35,8 @@ const assert = require('assert'); cli.output, /\d+: node:internal\/buffer/, 'includes node-internal scripts'); - }) - .then(() => cli.quit()) - .then(null, onFatal); + } finally { + await cli.quit(); + } + })().then(common.mustCall()); }