1'use strict';
2const common = require('../common');
3
4common.skipIfInspectorDisabled();
5
6const fixtures = require('../common/fixtures');
7const startCLI = require('../common/debugger');
8
9const assert = require('assert');
10const path = require('path');
11
12// Using sb before loading file.
13
14const scriptFullPath = fixtures.path('debugger', 'cjs', 'index.js');
15const script = path.relative(process.cwd(), scriptFullPath);
16
17const otherScriptFullPath = fixtures.path('debugger', 'cjs', 'other.js');
18const otherScript = path.relative(process.cwd(), otherScriptFullPath);
19
20const cli = startCLI(['--port=0', script]);
21
22(async () => {
23  await cli.waitForInitialBreak();
24  await cli.waitForPrompt();
25  await cli.command('sb("other.js", 2)');
26  assert.match(cli.output, /not loaded yet/,
27               'warns that the script was not loaded yet');
28  await cli.stepCommand('cont');
29  assert.ok(cli.output.includes(`break in ${otherScript}:2`),
30            'found breakpoint in file that was not loaded yet');
31})()
32.then(common.mustCall())
33.finally(() => cli.quit());
34