forked from nodejs/node
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add test for exception handlings in debugger
PR-URL: nodejs#42327 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Antoine du Hamel <[email protected]> Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Daijiro Wachi <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]>
- Loading branch information
Showing
1 changed file
with
42 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
}); | ||
})); | ||
} |