node/test/sequential/test-worker-heapsnapshot-options.js
Joyee Cheung b872d30d19
lib: add options to the heap snapshot APIs
Support configuration of the HeapSnapshotMode and NumericsMode
fields inf HeapSnapshotOptions in the JS APIs for heap snapshots.

PR-URL: https://github.com/nodejs/node/pull/44989
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
2022-11-08 16:19:54 +01:00

22 lines
621 B
JavaScript

// Flags: --expose-internals
'use strict';
const common = require('../common');
const { recordState, getHeapSnapshotOptionTests } = require('../common/heap');
const { Worker } = require('worker_threads');
const { once } = require('events');
(async function() {
const tests = getHeapSnapshotOptionTests();
const w = new Worker(tests.fixtures);
await once(w, 'message');
for (const { options, expected } of tests.cases) {
const stream = await w.getHeapSnapshot(options);
const snapshot = recordState(stream);
tests.check(snapshot, expected);
}
await w.terminate();
})().then(common.mustCall());