• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1'use strict';
2
3const common = require('../common');
4
5common.skipIfInspectorDisabled();
6
7const assert = require('assert');
8
9const RESTARTS = 10;
10
11const fixtures = require('../common/fixtures');
12const startCLI = require('../common/debugger');
13
14// Using `restart` should result in only one "Connect/For help" message.
15{
16  const script = fixtures.path('debugger', 'three-lines.js');
17  const cli = startCLI([script]);
18
19  function onFatal(error) {
20    cli.quit();
21    throw error;
22  }
23
24  const listeningRegExp = /Debugger listening on/g;
25
26  cli.waitForInitialBreak()
27    .then(() => cli.waitForPrompt())
28    .then(() => {
29      assert.strictEqual(cli.output.match(listeningRegExp).length, 1);
30    })
31    .then(async () => {
32      for (let i = 0; i < RESTARTS; i++) {
33        await cli.stepCommand('restart');
34        assert.strictEqual(cli.output.match(listeningRegExp).length, 1);
35      }
36    })
37    .then(() => cli.quit())
38    .then(null, onFatal);
39}
40