• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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{
14  const scriptFullPath = fixtures.path('debugger', 'cjs', 'index.js');
15  const script = path.relative(process.cwd(), scriptFullPath);
16
17  const otherScriptFullPath = fixtures.path('debugger', 'cjs', 'other.js');
18  const otherScript = path.relative(process.cwd(), otherScriptFullPath);
19
20  const cli = startCLI([script]);
21
22  function onFatal(error) {
23    cli.quit();
24    throw error;
25  }
26
27  cli.waitForInitialBreak()
28    .then(() => cli.waitForPrompt())
29    .then(() => cli.command('sb("other.js", 2)'))
30    .then(() => {
31      assert.match(
32        cli.output,
33        /not loaded yet/,
34        'warns that the script was not loaded yet');
35    })
36    .then(() => cli.stepCommand('cont'))
37    .then(() => {
38      assert.ok(
39        cli.output.includes(`break in ${otherScript}:2`),
40        'found breakpoint in file that was not loaded yet');
41    })
42    .then(() => cli.quit())
43    .then(null, onFatal);
44}
45