1import { skipIfInspectorDisabled } from '../common/index.mjs'; 2skipIfInspectorDisabled(); 3 4import { path } from '../common/fixtures.mjs'; 5import startCLI from '../common/debugger.js'; 6 7import assert from 'assert'; 8 9const script = path('debugger', 'twenty-lines.js'); 10const cli = startCLI(['--port=0', script]); 11 12function onFatal(error) { 13 cli.quit(); 14 throw error; 15} 16 17function getLastLine(output) { 18 const splittedByLine = output.split(';'); 19 return splittedByLine[splittedByLine.length - 2]; 20} 21 22// Stepping through breakpoints. 23try { 24 await cli.waitForInitialBreak(); 25 await cli.waitForPrompt(); 26 27 await cli.command('setContextLineNumber("1")'); 28 assert.ok(cli.output.includes('argument must be of type number. Received type string')); 29 30 await cli.command('setContextLineNumber(0)'); 31 assert.ok(cli.output.includes('It must be >= 1. Received 0')); 32 33 // Make sure the initial value is 2. 34 await cli.stepCommand('n'); 35 assert.ok(getLastLine(cli.output).includes('4 x = 3')); 36 37 await cli.command('setContextLineNumber(5)'); 38 await cli.stepCommand('n'); 39 assert.ok(getLastLine(cli.output).includes('8 x = 7')); 40 41 await cli.command('setContextLineNumber(3)'); 42 await cli.stepCommand('n'); 43 assert.ok(getLastLine(cli.output).includes('7 x = 6')); 44 await cli.command('list(3)'); 45 assert.ok(getLastLine(cli.output).includes('7 x = 6')); 46 47 await cli.quit(); 48} catch (error) { 49 onFatal(error); 50} 51