From de80e864c3d3e228dfab0474da4aba25778c9c54 Mon Sep 17 00:00:00 2001 From: Meek Simbule <55823259+meekdenzo@users.noreply.github.com> Date: Thu, 23 Jun 2022 15:52:05 -0500 Subject: [PATCH] test: refactor to top-level await PR-URL: https://github.com/nodejs/node/pull/43500 Reviewed-By: Rich Trott Reviewed-By: Antoine du Hamel Reviewed-By: Luigi Pinca --- ...r-address.js => test-debugger-address.mjs} | 47 +++++++++---------- 1 file changed, 22 insertions(+), 25 deletions(-) rename test/parallel/{test-debugger-address.js => test-debugger-address.mjs} (57%) diff --git a/test/parallel/test-debugger-address.js b/test/parallel/test-debugger-address.mjs similarity index 57% rename from test/parallel/test-debugger-address.js rename to test/parallel/test-debugger-address.mjs index e8cfd428ebcb05..eab99c9b0e2fb3 100644 --- a/test/parallel/test-debugger-address.js +++ b/test/parallel/test-debugger-address.mjs @@ -1,13 +1,12 @@ -'use strict'; -const common = require('../common'); +import { skipIfInspectorDisabled } from '../common/index.mjs'; -common.skipIfInspectorDisabled(); +skipIfInspectorDisabled(); -const fixtures = require('../common/fixtures'); -const startCLI = require('../common/debugger'); +import * as fixtures from '../common/fixtures.mjs'; +import startCLI from '../common/debugger.js'; -const assert = require('assert'); -const { spawn } = require('child_process'); +import assert from 'assert'; +import { spawn } from 'child_process'; // NOTE(oyyd): We might want to import this regexp from "lib/_inspect.js"? const kDebuggerMsgReg = /Debugger listening on ws:\/\/\[?(.+?)\]?:(\d+)\//; @@ -53,22 +52,20 @@ function launchTarget(...args) { assert.ifError(error); } - (async () => { - try { - const { childProc, host, port } = await launchTarget('--inspect=0', script); - target = childProc; - cli = startCLI([`${host || '127.0.0.1'}:${port}`]); - await cli.waitForPrompt(); - await cli.command('sb("alive.js", 3)'); - await cli.waitFor(/break/); - await cli.waitForPrompt(); - assert.match( - cli.output, - /> 3 {3}\+\+x;/, - 'marks the 3rd line' - ); - } finally { - cleanup(); - } - })().then(common.mustCall()); + try { + const { childProc, host, port } = await launchTarget('--inspect=0', script); + target = childProc; + cli = startCLI([`${host || '127.0.0.1'}:${port}`]); + await cli.waitForPrompt(); + await cli.command('sb("alive.js", 3)'); + await cli.waitFor(/break/); + await cli.waitForPrompt(); + assert.match( + cli.output, + /> 3 {3}\+\+x;/, + 'marks the 3rd line' + ); + } finally { + cleanup(); + } }