summaryrefslogtreecommitdiff
path: root/test/parallel/test-inspector-heapdump.js
blob: 4520de731fa57d92343d6fbb25dd5cbddac23422 (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
'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.mustCall((e, r) => {
  assert.ifError(e);
  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);
}));