UNPKG

jest-snapshot-serializer-ansi

Version:
14 lines (13 loc) 438 B
import hasAnsi from 'has-ansi'; import stripAnsi from 'strip-ansi'; export function test(value) { const text = value instanceof Error ? value.message : value; return typeof text === 'string' && hasAnsi(text); } export function print(value, serialize) { if (value instanceof Error) { return `[${value.name}: ${stripAnsi(value.message)}]`; } return serialize(stripAnsi(value)); } export default { test, print };