diff --git a/packages/vitest/src/node/error.ts b/packages/vitest/src/node/error.ts index d4e94fb7018f..610838dcb1d2 100644 --- a/packages/vitest/src/node/error.ts +++ b/packages/vitest/src/node/error.ts @@ -5,6 +5,7 @@ import c from 'picocolors' import cliTruncate from 'cli-truncate' import type { StackTraceParserOptions } from '@vitest/utils/source-map' import { inspect } from '@vitest/utils' +import stripAnsi from 'strip-ansi' import type { ErrorWithDiff, ParsedStack } from '../types' import { lineSplitRE, parseErrorStacktrace, positionToOffset } from '../utils/source-map' import { F_POINTER } from '../utils/figures' @@ -290,7 +291,7 @@ export function generateCodeFrame( const lineLength = lines[j].length // to long, maybe it's a minified file, skip for codeframe - if (lineLength > 200) + if (stripAnsi(lines[j]).length > 200) return '' res.push(lineNo(j + 1) + cliTruncate(lines[j].replace(/\t/g, ' '), columns - 5 - indent))