0
0
mirror of https://github.com/nodejs/node.git synced 2024-11-21 21:19:50 +01:00
nodejs/test/parallel/test-debugger-invalid-json.mjs
Anjana Krishnakumar Vellore 70047b0c34
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 <rtrott@gmail.com>
2022-09-29 19:54:46 +00:00

47 lines
1013 B
JavaScript

import { skipIfInspectorDisabled, mustCall } from '../common/index.mjs';
skipIfInspectorDisabled();
import startCLI from '../common/debugger.js';
import assert from 'assert';
import http from 'http';
const host = '127.0.0.1';
{
const server = http.createServer((req, res) => {
res.statusCode = 400;
res.end('Bad Request');
});
server.listen(0, mustCall(async () => {
const port = server.address().port;
const cli = startCLI([`${host}:${port}`]);
try {
const code = await cli.quit();
assert.strictEqual(code, 1);
} finally {
server.close();
}
}));
}
{
const server = http.createServer((req, res) => {
res.statusCode = 200;
res.end('some data that is invalid json');
});
server.listen(0, host, mustCall(async () => {
const port = server.address().port;
const cli = startCLI([`${host}:${port}`]);
try {
const code = await cli.quit();
assert.strictEqual(code, 1);
} finally {
server.close();
}
}));
}