1import { skipIfInspectorDisabled, mustCall } from '../common/index.mjs'; 2 3skipIfInspectorDisabled(); 4 5import startCLI from '../common/debugger.js'; 6 7import assert from 'assert'; 8import http from 'http'; 9 10const host = '127.0.0.1'; 11 12{ 13 const server = http.createServer((req, res) => { 14 res.statusCode = 400; 15 res.end('Bad Request'); 16 }); 17 18 server.listen(0, mustCall(async () => { 19 const port = server.address().port; 20 const cli = startCLI([`${host}:${port}`]); 21 try { 22 const code = await cli.quit(); 23 assert.strictEqual(code, 1); 24 } finally { 25 server.close(); 26 } 27 })); 28} 29 30{ 31 const server = http.createServer((req, res) => { 32 res.statusCode = 200; 33 res.end('some data that is invalid json'); 34 }); 35 36 server.listen(0, host, mustCall(async () => { 37 const port = server.address().port; 38 const cli = startCLI([`${host}:${port}`]); 39 try { 40 const code = await cli.quit(); 41 assert.strictEqual(code, 1); 42 } finally { 43 server.close(); 44 } 45 })); 46} 47