Skip to content

Commit

Permalink
fix: improve test name escaping in TAP reporters (#1367)
Browse files Browse the repository at this point in the history
  • Loading branch information
Demivan committed May 24, 2022
1 parent cc17448 commit f8db7d7
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions packages/vitest/src/node/reporters/tap.ts
Expand Up @@ -8,9 +8,10 @@ function yamlString(str: string): string {
}

function tapString(str: string): string {
// Test name cannot contain #
// Test name cannot start with number
return str.replace(/#/g, '?').replace(/^[0-9]+/, '?')
return str
.replace(/\\/g, '\\\\') // escape slashes
.replace(/#/g, '\\#') // escape #
.replace(/\n/g, ' ') // remove newlines
}

export class TapReporter implements Reporter {
Expand Down

0 comments on commit f8db7d7

Please sign in to comment.