Skip to content

Commit 2b08167

Browse files
committed
test: add test for exception handlings in debugger
1 parent b35ee26 commit 2b08167

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
'use strict';
2+
const common = require('../common');
3+
const startCLI = require('../common/debugger');
4+
5+
common.skipIfInspectorDisabled();
6+
7+
const assert = require('assert');
8+
const http = require('http');
9+
10+
const host = '127.0.0.1';
11+
12+
const testWhenBadRequest = () => {
13+
const server = http.createServer((req, res) => {
14+
res.statusCode = 400;
15+
res.end('Bad Request');
16+
});
17+
server.listen(0, async () => {
18+
try {
19+
const port = server.address().port;
20+
const cli = startCLI([`${host}:${port}`]);
21+
const code = await cli.quit();
22+
assert.strictEqual(code, 1);
23+
} finally {
24+
server.close();
25+
}
26+
});
27+
};
28+
29+
const testInvalidJson = () => {
30+
const server = http.createServer((req, res) => {
31+
res.statusCode = 200;
32+
res.end('ok');
33+
});
34+
server.listen(0, host, async () => {
35+
try {
36+
const port = server.address().port;
37+
const cli = startCLI([`${host}:${port}`]);
38+
const code = await cli.quit();
39+
assert.strictEqual(code, 1);
40+
} finally {
41+
server.close();
42+
}
43+
});
44+
};
45+
46+
testWhenBadRequest();
47+
testInvalidJson();

0 commit comments

Comments
 (0)