node/test/pummel/test-worker-take-heapsnapshot.js
Rich Trott 330f25ef82 test: prepare for consistent comma-dangle lint rule
Make changes so that tests will pass when the comma-dangle settings
applied to the rest of the code base are also applied to tests.

PR-URL: https://github.com/nodejs/node/pull/37930
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Derek Lewis <DerekNonGeneric@inf.is>
2021-04-01 23:14:29 -07:00

23 lines
651 B
JavaScript

// Flags: --expose-internals
'use strict';
const common = require('../common');
const { recordState } = require('../common/heap');
const { Worker } = require('worker_threads');
const { once } = require('events');
(async function() {
const w = new Worker('setInterval(() => {}, 100)', { eval: true });
await once(w, 'online');
const stream = await w.getHeapSnapshot();
const snapshot = recordState(stream);
snapshot.validateSnapshot('Node / MessagePort', [
{
children: [
{ node_name: 'Node / MessagePortData', edge_name: 'data' },
]
},
], { loose: true });
await w.terminate();
})().then(common.mustCall());