node/test/parallel/test-process-features.js
Joyee Cheung b0f025208f
process: add process.features.require_module
For detecting whether `require(esm)` is supported without triggering
the experimental warning.

PR-URL: https://github.com/nodejs/node/pull/55241
Reviewed-By: Richard Lau <rlau@redhat.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
2024-10-07 15:26:10 +00:00

26 lines
743 B
JavaScript

'use strict';
require('../common');
const assert = require('assert');
const actualKeys = new Set(Object.keys(process.features));
const expectedKeys = new Map([
['inspector', ['boolean']],
['debug', ['boolean']],
['uv', ['boolean']],
['ipv6', ['boolean']],
['tls_alpn', ['boolean']],
['tls_sni', ['boolean']],
['tls_ocsp', ['boolean']],
['tls', ['boolean']],
['cached_builtins', ['boolean']],
['require_module', ['boolean']],
['typescript', ['boolean', 'string']],
]);
assert.deepStrictEqual(actualKeys, new Set(expectedKeys.keys()));
for (const [key, expected] of expectedKeys) {
assert.ok(expected.includes(typeof process.features[key]), `typeof process.features.${key} is not one of [${expected.join(', ')}]`);
}