replace-stack-traces
v2.0.0
Published
A JavaScript function to replace error stack traces and following Node.js versions at any indent in a multiline string.
Downloads
27
Maintainers
Readme
replace-stack-traces
A JavaScript function to replace error stack traces and following Node.js versions at any indent in a multiline string.
Useful for snapshot testing CLI stderr output containing error stack traces, because:
- Different Node.js versions generate different error stack traces, and v17.0.0+ appends the Node.js version if the error caused the process to exit.
- Editing modules that affect the line and column numbers, etc. in the error stack traces requires the snapshots to be updated annoyingly often.
Installation
For Node.js, to install replace-stack-traces
with npm, run:
npm install replace-stack-traces
For Deno, an example import map:
{
"imports": {
"replace-stack-traces": "https://unpkg.com/[email protected]/replaceStackTraces.mjs"
}
}
Requirements
Supported runtime environments:
Non Deno projects must configure TypeScript to use types from the ECMAScript modules that have a // @ts-check
comment:
compilerOptions.allowJs
should betrue
.compilerOptions.maxNodeModuleJsDepth
should be reasonably large, e.g.10
.compilerOptions.module
should be"node16"
or"nodenext"
.
Exports
The npm package replace-stack-traces
features optimal JavaScript module design. These ECMAScript modules are exported via the package.json
field exports
: