Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
test: add test for exception handlings in debugger
  • Loading branch information
cola119 committed Mar 14, 2022
commit 2b0816713b1f6044ad4ea2fbb45ddfbb9507d0d7
47 changes: 47 additions & 0 deletions test/parallel/test-debugger-invalid-json.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
'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 testWhenBadRequest = () => {
Comment thread
cola119 marked this conversation as resolved.
Outdated
const server = http.createServer((req, res) => {
res.statusCode = 400;
res.end('Bad Request');
});
server.listen(0, async () => {
try {
const port = server.address().port;
const cli = startCLI([`${host}:${port}`]);
const code = await cli.quit();
assert.strictEqual(code, 1);
} finally {
server.close();
}
});
Comment thread
cola119 marked this conversation as resolved.
Outdated
};

const testInvalidJson = () => {
Comment thread
cola119 marked this conversation as resolved.
Outdated
const server = http.createServer((req, res) => {
res.statusCode = 200;
res.end('ok');
Comment thread
cola119 marked this conversation as resolved.
Outdated
});
server.listen(0, host, async () => {
try {
const port = server.address().port;
const cli = startCLI([`${host}:${port}`]);
const code = await cli.quit();
assert.strictEqual(code, 1);
} finally {
server.close();
}
});
Comment thread
cola119 marked this conversation as resolved.
Outdated
};

testWhenBadRequest();
testInvalidJson();
Comment thread
cola119 marked this conversation as resolved.
Outdated