0
0
mirror of https://github.com/nodejs/node.git synced 2024-12-01 16:10:02 +01:00
nodejs/deps/node-inspect/test/cli/heap-profiler.test.js
Jan Krems 02b3bbc5e2
deps: update node-inspect to 1.11.3
Highlights:

* Using a random port works (`node inspect --port=0 script.js`)
* `takeHeapSnapshot()` creates valid snapshots again

PR-URL: https://github.com/nodejs/node/pull/18354
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
2018-02-01 13:39:40 +01:00

35 lines
756 B
JavaScript

'use strict';
const { test } = require('tap');
const { readFileSync, unlinkSync } = require('fs');
const startCLI = require('./start-cli');
const filename = 'node.heapsnapshot';
function cleanup() {
try {
unlinkSync(filename);
} catch (_) {
// Ignore.
}
}
cleanup();
test('Heap profiler take snapshot', (t) => {
const cli = startCLI(['examples/empty.js']);
function onFatal(error) {
cli.quit();
throw error;
}
// Check that the snapshot is valid JSON.
return cli.waitForInitialBreak()
.then(() => cli.waitForPrompt())
.then(() => cli.command('takeHeapSnapshot()'))
.then(() => JSON.parse(readFileSync(filename, 'utf8')))
.then(() => cleanup())
.then(() => cli.quit())
.then(null, onFatal);
});