node/test/pummel/test-heapdump-urlpattern.js
Joyee Cheung e86adad759 test: use validateByRetainingPath in heapdump tests
This makes sure that the tests are run on actual heap snapshots
and prints out missing paths when it cannot be found, which
makes failures easier to debug, and removes the unnecessary
requirement for BaseObjects to be root - which would make
the heap snapshot containment view rather noisy and is not
conceptually correct, since they are actually held by the
BaseObjectList held by the realms.

PR-URL: https://github.com/nodejs/node/pull/57417
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
2025-04-27 19:00:05 +00:00

24 lines
848 B
JavaScript

'use strict';
// This tests heap snapshot integration of URLPattern.
require('../common');
const { validateByRetainingPath } = require('../common/heap');
const { URLPattern } = require('node:url');
const assert = require('assert');
// Before url pattern is used, no URLPattern should be created.
{
const nodes = validateByRetainingPath('Node / URLPattern', []);
assert.strictEqual(nodes.length, 0);
}
const urlPattern = new URLPattern('https://example.com/:id');
// After url pattern is used, a URLPattern should be created.
validateByRetainingPath('Node / URLPattern', [
{ node_name: 'Node / ada::url_pattern', edge_name: 'url_pattern' },
// ada::url_pattern references ada::url_pattern_component.
{ node_name: 'Node / ada::url_pattern_component', edge_name: 'protocol_component' },
]);
// Use `urlPattern`.
console.log(urlPattern);