fix: improve test name escaping in TAP reporters (#1367)

This commit is contained in:
Ivan Demchuk 2022-05-25 00:48:52 +03:00 committed by GitHub
parent cc17448c74
commit f8db7d7346
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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 {