(text: unknown)
| 272 | } |
| 273 | |
| 274 | export function stabilizeResponseOutput(text: unknown) { |
| 275 | if (typeof text !== 'string') { |
| 276 | throw new Error('Input must be string'); |
| 277 | } |
| 278 | let output = text; |
| 279 | const dateRegEx = /.{3}, \d{2} .{3} \d{4} \d{2}:\d{2}:\d{2} [A-Z]{3}/g; |
| 280 | output = output.replaceAll(dateRegEx, '<long date>'); |
| 281 | |
| 282 | const localhostRegEx = /localhost:\d{5}/g; |
| 283 | output = output.replaceAll(localhostRegEx, 'localhost:<port>'); |
| 284 | |
| 285 | const userAgentRegEx = /user-agent:.*\n/g; |
| 286 | output = output.replaceAll(userAgentRegEx, 'user-agent:<user-agent>\n'); |
| 287 | |
| 288 | const chUaRegEx = /sec-ch-ua:"Chromium";v="\d{3}"/g; |
| 289 | output = output.replaceAll(chUaRegEx, 'sec-ch-ua:"Chromium";v="<version>"'); |
| 290 | |
| 291 | // sec-ch-ua-platform:"Linux" |
| 292 | const chUaPlatformRegEx = /sec-ch-ua-platform:"[a-zA-Z]*"/g; |
| 293 | output = output.replaceAll(chUaPlatformRegEx, 'sec-ch-ua-platform:"<os>"'); |
| 294 | |
| 295 | const savedSnapshot = /Saved snapshot to (.*)/g; |
| 296 | output = output.replaceAll(savedSnapshot, 'Saved snapshot to <file>'); |
| 297 | |
| 298 | const acceptLanguageRegEx = /accept-language:.*\n/g; |
| 299 | output = output.replaceAll(acceptLanguageRegEx, 'accept-language:<lang>\n'); |
| 300 | |
| 301 | // Stabilize URL-encoded file paths |
| 302 | const fileUriRegEx = /file%3A%2F%2F%2F[^)\n]+/g; |
| 303 | output = output.replaceAll(fileUriRegEx, '<file-path>'); |
| 304 | |
| 305 | return output; |
| 306 | } |
| 307 | |
| 308 | export function getMockAggregatedIssue(): sinon.SinonStubbedInstance<DevTools.AggregatedIssue> { |
| 309 | const mockAggregatedIssue = sinon.createStubInstance( |
no outgoing calls
no test coverage detected
searching dependent graphs…