node/test/parallel/test-inspector-heapdump.js
Tobias Nießen 30fb4a015d test: add common.mustSucceed
PR-URL: https://github.com/nodejs/node/pull/35086
Reviewed-By: Ruy Adorno <ruyadorno@github.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2020-10-17 00:48:26 +02:00

30 lines
747 B
JavaScript

'use strict';
const common = require('../common');
common.skipIfInspectorDisabled();
// Test that example code in doc/api/inspector.md continues to work with the V8
// experimental API.
const assert = require('assert');
const inspector = require('inspector');
const session = new inspector.Session();
session.connect();
const chunks = [];
session.on('HeapProfiler.addHeapSnapshotChunk', (m) => {
chunks.push(m.params.chunk);
});
session.post('HeapProfiler.takeHeapSnapshot', null, common.mustSucceed((r) => {
assert.deepStrictEqual(r, {});
session.disconnect();
const profile = JSON.parse(chunks.join(''));
assert(profile.snapshot.meta);
assert(profile.snapshot.node_count > 0);
assert(profile.snapshot.edge_count > 0);
}));