🚀 Feature: Support running with node --frozen-intrinsics #5252
Open
Description
opened on Nov 13, 2024
Feature Request Checklist
- I have read and agree to Mocha's Code of Conduct and Contributing Guidelines
- I have searched for related issues and issues with the
faq
label, but none matched my issue. - I want to provide a PR to resolve this
Overview
When node is invoked with the experimental --frozen-intrinsics flag (added in Node.js 11.12 by nodejs/node#25685) it causes mocha to exit due to an uncaught TypeError
from attempting to set Error.stackTraceLimit
:
/path/to/node_modules/mocha/lib/cli/cli.js:45
Error.stackTraceLimit = Infinity; // configurable via --stack-trace-limit?
^
TypeError <Object <Object <[Object: null prototype] {}>>>: Cannot assign to read only property 'stackTraceLimit' of function 'function Error() { [native code] }'
at exports.main (/path/to/node_modules/mocha/lib/cli/cli.js:45:25)
at Object.<anonymous> (/path/to/node_modules/mocha/bin/mocha.js:141:29)
at Module._compile (node:internal/modules/cjs/loader:1469:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1548:10)
at Module.load (node:internal/modules/cjs/loader:1288:32)
at Module._load (node:internal/modules/cjs/loader:1104:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:174:12)
at node:internal/main/run_main_module:28:49
It would be nice if mocha supported running under --frozen-intrinsics
for testing code under this flag.
Suggested Solution
Wrapping
Line 45 in d3b2c38
in try-catch
appears to be sufficient.
Alternatives
Not supporting running under --frozen-intrinsics
? (yet)
Additional Info
No response
Activity