(expected: RequestSnapshot, received: RequestSnapshot)
| 71 | }) |
| 72 | |
| 73 | export const requestDiff = (expected: RequestSnapshot, received: RequestSnapshot): ReadonlyArray<string> => { |
| 74 | const lines: string[] = [] |
| 75 | if (expected.method !== received.method) { |
| 76 | lines.push("method:", ` expected ${expected.method}, received ${received.method}`) |
| 77 | } |
| 78 | if (expected.url !== received.url) { |
| 79 | lines.push("url:", ` expected ${expected.url}`, ` received ${received.url}`) |
| 80 | } |
| 81 | const headers = headerDiffs(expected.headers, received.headers) |
| 82 | if (headers.length > 0) lines.push("headers:", ...headers.slice(0, 8)) |
| 83 | const expectedBody = jsonBody(expected.body) |
| 84 | const receivedBody = jsonBody(received.body) |
| 85 | const body = |
| 86 | expectedBody !== undefined && receivedBody !== undefined |
| 87 | ? valueDiffs(expectedBody, receivedBody).map((line) => ` ${line}`) |
| 88 | : expected.body === received.body |
| 89 | ? [] |
| 90 | : [` expected ${safeText(expected.body)}, received ${safeText(received.body)}`] |
| 91 | if (body.length > 0) lines.push("body:", ...body) |
| 92 | return lines |
| 93 | } |
| 94 | |
| 95 | export const selectSequential = ( |
| 96 | interactions: ReadonlyArray<HttpInteraction>, |
no test coverage detected