( line: string, config: StackTraceConfig, relativeTestPath: string | null = null, )
| 288 | }; |
| 289 | |
| 290 | export const formatPath = ( |
| 291 | line: string, |
| 292 | config: StackTraceConfig, |
| 293 | relativeTestPath: string | null = null, |
| 294 | ): string => { |
| 295 | // Extract the file path from the trace line. |
| 296 | const match = line.match(/(^\s*at .*?\(?)([^()]+)(:\d+:\d+\)?.*$)/); |
| 297 | if (!match) { |
| 298 | return line; |
| 299 | } |
| 300 | |
| 301 | let filePath = slash(path.relative(config.rootDir, match[2])); |
| 302 | // highlight paths from the current test file |
| 303 | if ( |
| 304 | (config.testMatch && |
| 305 | config.testMatch.length > 0 && |
| 306 | picomatch(config.testMatch)(filePath)) || |
| 307 | filePath === relativeTestPath |
| 308 | ) { |
| 309 | filePath = chalk.reset.cyan(filePath); |
| 310 | } |
| 311 | return STACK_TRACE_COLOR(match[1]) + filePath + STACK_TRACE_COLOR(match[3]); |
| 312 | }; |
| 313 | |
| 314 | export function getStackTraceLines( |
| 315 | stack: string, |
no test coverage detected