Create function to format powerAssertContext object provided by power-assert at runtime. Version 1.2.0 is stable. Part of the power-assert-runtime ecosystem. Replaces legacy format function with configurable renderers. Allows custom renderer arrays, reducers, output offset, and line separator. Supports legacy renderer compatibility. Key differentiator: separates formatting concern from assertion, enabling detailed diff diagrams and comparison output.
npm install power-assert-context-formatterNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Demonstrates creating a formatter with file, assertion, diagram, and comparison renderers, then using it to format power-assert output.
Always provide at least one renderer in options.renderers array.
Transition to new renderer API, avoid legacy: true if possible.
Ensure power-assert and context-formatter versions are compatible. Check power-assert changelog for context format changes.
Pass constructor functions (e.g., FileRenderer), not instances (new FileRenderer()). For options, use { ctor: FileRenderer, options: {...} }.Ensure you call createFormatter() and assign its return value to a variable: var format = createFormatter({...});Check that the error object has a powerAssertContext property. If using power-assert properly, this should be present on assertion errors.
Pass an array of renderer constructor functions to createFormatter({ renderers: [...] }).No dependency data recorded yet.