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', 'break.js'); 10const cli = startCLI(['--port=0', script]); 11 12function onFatal(error) { 13 cli.quit(); 14 throw error; 15} 16 17// Stepping through breakpoints. 18try { 19 await cli.waitForInitialBreak(); 20 await cli.waitForPrompt(); 21 await cli.command('watch("x")'); 22 await cli.command('watch("\\"Hello\\"")'); 23 await cli.command('watch("42")'); 24 await cli.command('watch("NaN")'); 25 await cli.command('watch("true")'); 26 await cli.command('watch("[1, 2]")'); 27 await cli.command('watch("process.env")'); 28 await cli.command('watchers'); 29 30 assert.match(cli.output, /x is not defined/); 31 assert.match(cli.output, /1: "Hello" = 'Hello'/); 32 assert.match(cli.output, /2: 42 = 42/); 33 assert.match(cli.output, /3: NaN = NaN/); 34 assert.match(cli.output, /4: true = true/); 35 assert.match(cli.output, /5: \[1, 2\] = \[ 1, 2 \]/); 36 assert.match(cli.output, /6: process\.env =\n\s+\{[\s\S]+,\n\s+\.\.\. \}/, 37 'shows "..." for process.env'); 38 39 await cli.command('unwatch(4)'); 40 await cli.command('unwatch("42")'); 41 await cli.stepCommand('n'); 42 43 assert.match(cli.output, /0: x = 10/); 44 assert.match(cli.output, /1: "Hello" = 'Hello'/); 45 assert.match(cli.output, /2: NaN = NaN/); 46 assert.match(cli.output, /3: \[1, 2\] = \[ 1, 2 \]/); 47 assert.match( 48 cli.output, 49 /4: process\.env =\n\s+\{[\s\S]+,\n\s+\.\.\. \}/, 50 'shows "..." for process.env' 51 ); 52 53 await cli.quit(); 54} catch (error) { 55 onFatal(error); 56} 57