From f4f08be384c18a1b4e8b69863371b40906d5f481 Mon Sep 17 00:00:00 2001 From: Anjana Krishnakumar Vellore <54228505+anjanakvellore@users.noreply.github.com> Date: Thu, 29 Sep 2022 12:54:46 -0700 Subject: [PATCH] test: use await in test-debugger-invalid-json Changes the promises to async/await in test/parallel/test-debugger-invalid-json. PR-URL: https://github.com/nodejs/node/pull/44689 Reviewed-By: Rich Trott --- ...json.js => test-debugger-invalid-json.mjs} | 32 +++++++++++-------- 1 file changed, 18 insertions(+), 14 deletions(-) rename test/parallel/{test-debugger-invalid-json.js => test-debugger-invalid-json.mjs} (56%) diff --git a/test/parallel/test-debugger-invalid-json.js b/test/parallel/test-debugger-invalid-json.mjs similarity index 56% rename from test/parallel/test-debugger-invalid-json.js rename to test/parallel/test-debugger-invalid-json.mjs index 9bad8ed36949b2..e4754a465fcf5f 100644 --- a/test/parallel/test-debugger-invalid-json.js +++ b/test/parallel/test-debugger-invalid-json.mjs @@ -1,11 +1,11 @@ -'use strict'; -const common = require('../common'); -const startCLI = require('../common/debugger'); +import { skipIfInspectorDisabled, mustCall } from '../common/index.mjs'; -common.skipIfInspectorDisabled(); +skipIfInspectorDisabled(); -const assert = require('assert'); -const http = require('http'); +import startCLI from '../common/debugger.js'; + +import assert from 'assert'; +import http from 'http'; const host = '127.0.0.1'; @@ -14,14 +14,16 @@ const host = '127.0.0.1'; res.statusCode = 400; res.end('Bad Request'); }); - server.listen(0, common.mustCall(() => { + + server.listen(0, mustCall(async () => { const port = server.address().port; const cli = startCLI([`${host}:${port}`]); - cli.quit().then(common.mustCall((code) => { + try { + const code = await cli.quit(); assert.strictEqual(code, 1); - })).finally(() => { + } finally { server.close(); - }); + } })); } @@ -30,13 +32,15 @@ const host = '127.0.0.1'; res.statusCode = 200; res.end('some data that is invalid json'); }); - server.listen(0, host, common.mustCall(() => { + + server.listen(0, host, mustCall(async () => { const port = server.address().port; const cli = startCLI([`${host}:${port}`]); - cli.quit().then(common.mustCall((code) => { + try { + const code = await cli.quit(); assert.strictEqual(code, 1); - })).finally(() => { + } finally { server.close(); - }); + } })); }