Skip to content

Commit

Permalink
test: add test for exception handlings in debugger
Browse files Browse the repository at this point in the history
PR-URL: #42327
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Daijiro Wachi <daijiro.wachi@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
  • Loading branch information
cola119 authored and juanarbol committed Apr 6, 2022
1 parent f45d553 commit 797994e
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions test/parallel/test-debugger-invalid-json.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
'use strict';
const common = require('../common');
const startCLI = require('../common/debugger');

common.skipIfInspectorDisabled();

const assert = require('assert');
const http = require('http');

const host = '127.0.0.1';

{
const server = http.createServer((req, res) => {
res.statusCode = 400;
res.end('Bad Request');
});
server.listen(0, common.mustCall(() => {
const port = server.address().port;
const cli = startCLI([`${host}:${port}`]);
cli.quit().then(common.mustCall((code) => {
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, common.mustCall(() => {
const port = server.address().port;
const cli = startCLI([`${host}:${port}`]);
cli.quit().then(common.mustCall((code) => {
assert.strictEqual(code, 1);
})).finally(() => {
server.close();
});
}));
}

0 comments on commit 797994e

Please sign in to comment.