Skip to content

Commit

Permalink
limit prettyFormat plugins to DOM plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
patinthehat authored and Patrick committed Mar 1, 2021
1 parent 0788e7e commit 61b5109
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/ArgumentConverter.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import prettyFormat from 'pretty-format';
const PrettyFormatPluginDomCollection = require('pretty-format/build/plugins/DOMCollection');
const PrettyFormatPluginDomElement = require('pretty-format/build/plugins/DOMElement');

export interface ArgumentConverterResult {
value: any;
Expand Down Expand Up @@ -27,7 +29,10 @@ export class ArgumentConverter {
}

public static prettyFormatForHtml(arg: any): string {
const formatted = prettyFormat(arg, { indent: 4 })
const formatted = prettyFormat(arg, {
plugins: [PrettyFormatPluginDomCollection, PrettyFormatPluginDomElement],
indent: 4,
})
// format whitespace for display in html
.replace(/ /g, ' ')
.replace(/\r\n|\r|\n/g, '<br>')
Expand Down

0 comments on commit 61b5109

Please sign in to comment.