test: change promises to async/await

PR-URL: https://github.com/nodejs/node/pull/44683
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Rich Trott <rtrott@gmail.com>
This commit is contained in:
Madhulika Sharma 2022-09-26 02:19:11 -04:00 committed by GitHub
parent e58c7ccc97
commit 1e6153c090
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 36 additions and 47 deletions

View File

@ -1,47 +0,0 @@
'use strict';
const common = require('../common');
common.skipIfInspectorDisabled();
const fixtures = require('../common/fixtures');
const startCLI = require('../common/debugger');
const assert = require('assert');
{
const script = fixtures.path('debugger', 'three-lines.js');
const cli = startCLI([script]);
cli.waitForInitialBreak()
.then(() => cli.waitForPrompt())
.then(() => {
assert.match(cli.output, /debug>/, 'prints a prompt');
assert.match(
cli.output,
/< Debugger listening on [^\n]*9229/,
'forwards child output');
})
.then(() => cli.command('["hello", "world"].join(" ")'))
.then(() => {
assert.match(cli.output, /hello world/, 'prints the result');
})
.then(() => cli.command(''))
.then(() => {
assert.match(
cli.output,
/hello world/,
'repeats the last command on <enter>'
);
})
.then(() => cli.command('version'))
.then(() => {
assert.ok(
cli.output.includes(process.versions.v8),
'version prints the v8 version'
);
})
.then(() => cli.quit())
.then((code) => {
assert.strictEqual(code, 0);
});
}

View File

@ -0,0 +1,36 @@
import { skipIfInspectorDisabled } from '../common/index.mjs';
skipIfInspectorDisabled();
import { path } from '../common/fixtures.mjs';
import startCLI from '../common/debugger.js';
import assert from 'assert';
const script = path('debugger', 'three-lines.js');
const cli = startCLI([script]);
try {
await cli.waitForInitialBreak();
await cli.waitForPrompt();
assert.match(cli.output, /debug>/, 'prints a prompt');
assert.match(
cli.output,
/< Debugger listening on [^\n]*9229/,
'forwards child output'
);
await cli.command('["hello", "world"].join(" ")');
assert.match(cli.output, /hello world/, 'prints the result');
await cli.command('');
assert.match(
cli.output,
/hello world/,
'repeats the last command on <enter>'
);
await cli.command('version');
assert.ok(
cli.output.includes(process.versions.v8),
'version prints the v8 version'
);
} finally {
const code = await cli.quit();
assert.strictEqual(code, 0);
}