• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1'use strict';
2const { test } = require('tap');
3
4const startCLI = require('./start-cli');
5
6test('stepping through breakpoints', (t) => {
7  const cli = startCLI(['examples/break.js']);
8
9  function onFatal(error) {
10    cli.quit();
11    throw error;
12  }
13
14  return cli.waitForInitialBreak()
15    .then(() => cli.waitForPrompt())
16    .then(() => cli.command('watch("x")'))
17    .then(() => cli.command('watch("\\"Hello\\"")'))
18    .then(() => cli.command('watch("42")'))
19    .then(() => cli.command('watch("NaN")'))
20    .then(() => cli.command('watch("true")'))
21    .then(() => cli.command('watch("[1, 2]")'))
22    .then(() => cli.command('watch("process.env")'))
23    .then(() => cli.command('watchers'))
24    .then(() => {
25      t.match(cli.output, 'x is not defined');
26    })
27    .then(() => cli.command('unwatch("42")'))
28    .then(() => cli.stepCommand('n'))
29    .then(() => {
30      t.match(cli.output, '0: x = 10');
31      t.match(cli.output, '1: "Hello" = \'Hello\'');
32      t.match(cli.output, '2: NaN = NaN');
33      t.match(cli.output, '3: true = true');
34      t.match(cli.output, '4: [1, 2] = [ 1, 2 ]');
35      t.match(
36        cli.output,
37        /5: process\.env =\n\s+\{[\s\S]+,\n\s+\.\.\. \}/,
38        'shows "..." for process.env');
39    })
40    .then(() => cli.quit())
41    .then(null, onFatal);
42});
43