• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1'use strict';
2const { test } = require('tap');
3
4const startCLI = require('./start-cli');
5
6function delay(ms) {
7  return new Promise((resolve) => setTimeout(resolve, ms));
8}
9
10test('profiles', (t) => {
11  const cli = startCLI(['examples/empty.js']);
12
13  function onFatal(error) {
14    cli.quit();
15    throw error;
16  }
17
18  return cli.waitForInitialBreak()
19    .then(() => cli.waitForPrompt())
20    .then(() => cli.command('exec console.profile()'))
21    .then(() => {
22      t.match(cli.output, 'undefined');
23    })
24    .then(() => cli.command('exec console.profileEnd()'))
25    .then(() => delay(250))
26    .then(() => {
27      t.match(cli.output, 'undefined');
28      t.match(cli.output, 'Captured new CPU profile.');
29    })
30    .then(() => cli.quit())
31    .then(null, onFatal);
32});
33