summaryrefslogtreecommitdiff
path: root/test/inspector-cli/test-inspector-cli-profile.js
blob: a683d78b06f204d4bc56cdfae397100be5e3845a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
'use strict';
const common = require('../common');

common.skipIfInspectorDisabled();

const fixtures = require('../common/fixtures');
const startCLI = require('../common/inspector-cli');

const assert = require('assert');

function delay(ms) {
  return new Promise((resolve) => setTimeout(resolve, ms));
}

// Profiles.
{
  const cli = startCLI([fixtures.path('inspector-cli/empty.js')]);

  function onFatal(error) {
    cli.quit();
    throw error;
  }

  return cli.waitForInitialBreak()
    .then(() => cli.waitForPrompt())
    .then(() => cli.command('exec console.profile()'))
    .then(() => {
      assert.match(cli.output, /undefined/);
    })
    .then(() => cli.command('exec console.profileEnd()'))
    .then(() => delay(250))
    .then(() => {
      assert.match(cli.output, /undefined/);
      assert.match(cli.output, /Captured new CPU profile\./);
    })
    .then(() => cli.quit())
    .then(null, onFatal);
}