Skip to content

Commit bd91337

Browse files
meekdenzotargos
authored andcommitted
test: refactor to top-level await
PR-URL: #43500 Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Antoine du Hamel <[email protected]> Reviewed-By: Luigi Pinca <[email protected]>
1 parent 919c5ee commit bd91337

File tree

1 file changed

+22
-25
lines changed

1 file changed

+22
-25
lines changed

test/parallel/test-debugger-address.js test/parallel/test-debugger-address.mjs

+22-25
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
1-
'use strict';
2-
const common = require('../common');
1+
import { skipIfInspectorDisabled } from '../common/index.mjs';
32

4-
common.skipIfInspectorDisabled();
3+
skipIfInspectorDisabled();
54

6-
const fixtures = require('../common/fixtures');
7-
const startCLI = require('../common/debugger');
5+
import * as fixtures from '../common/fixtures.mjs';
6+
import startCLI from '../common/debugger.js';
87

9-
const assert = require('assert');
10-
const { spawn } = require('child_process');
8+
import assert from 'assert';
9+
import { spawn } from 'child_process';
1110

1211
// NOTE(oyyd): We might want to import this regexp from "lib/_inspect.js"?
1312
const kDebuggerMsgReg = /Debugger listening on ws:\/\/\[?(.+?)\]?:(\d+)\//;
@@ -53,22 +52,20 @@ function launchTarget(...args) {
5352
assert.ifError(error);
5453
}
5554

56-
(async () => {
57-
try {
58-
const { childProc, host, port } = await launchTarget('--inspect=0', script);
59-
target = childProc;
60-
cli = startCLI([`${host || '127.0.0.1'}:${port}`]);
61-
await cli.waitForPrompt();
62-
await cli.command('sb("alive.js", 3)');
63-
await cli.waitFor(/break/);
64-
await cli.waitForPrompt();
65-
assert.match(
66-
cli.output,
67-
/> 3 {3}\+\+x;/,
68-
'marks the 3rd line'
69-
);
70-
} finally {
71-
cleanup();
72-
}
73-
})().then(common.mustCall());
55+
try {
56+
const { childProc, host, port } = await launchTarget('--inspect=0', script);
57+
target = childProc;
58+
cli = startCLI([`${host || '127.0.0.1'}:${port}`]);
59+
await cli.waitForPrompt();
60+
await cli.command('sb("alive.js", 3)');
61+
await cli.waitFor(/break/);
62+
await cli.waitForPrompt();
63+
assert.match(
64+
cli.output,
65+
/> 3 {3}\+\+x;/,
66+
'marks the 3rd line'
67+
);
68+
} finally {
69+
cleanup();
70+
}
7471
}

0 commit comments

Comments
 (0)