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
Prev Previous commit
fixup! test: add test for exception handlings in debugger
  • Loading branch information
cola119 committed Mar 14, 2022
commit dca80cd3d61cfe25888ee15cf5e242c0a9dca062
43 changes: 19 additions & 24 deletions test/parallel/test-debugger-invalid-json.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,39 +9,34 @@ const http = require('http');

const host = '127.0.0.1';

const testWhenBadRequest = () => {
{
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();
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 {
})).finally(() => {
server.close();
}
});
};
});
}));
}

const testInvalidJson = () => {
{
const server = http.createServer((req, res) => {
res.statusCode = 200;
res.end('ok');
res.end('some data that is invalid json');
});
server.listen(0, host, async () => {
try {
const port = server.address().port;
const cli = startCLI([`${host}:${port}`]);
const code = await cli.quit();
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 {
})).finally(() => {
server.close();
}
});
};

testWhenBadRequest();
testInvalidJson();
});
}));
}