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
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