( a: Record<string, any>, b: Record<string, any>, formatOptions: PrettyFormatOptions, options?: DiffOptions, memorize: Memorize = DEFAULT_MEMORIZE, )
| 227 | } |
| 228 | |
| 229 | function getObjectsDifference( |
| 230 | a: Record<string, any>, |
| 231 | b: Record<string, any>, |
| 232 | formatOptions: PrettyFormatOptions, |
| 233 | options?: DiffOptions, |
| 234 | memorize: Memorize = DEFAULT_MEMORIZE, |
| 235 | ): string { |
| 236 | const formatOptionsZeroIndent = { ...formatOptions, indent: 0 } |
| 237 | const aCompare = prettyFormat(a, formatOptionsZeroIndent) |
| 238 | const bCompare = prettyFormat(b, formatOptionsZeroIndent) |
| 239 | |
| 240 | if (aCompare === bCompare) { |
| 241 | return getCommonMessage(NO_DIFF_MESSAGE, options) |
| 242 | } |
| 243 | else { |
| 244 | const aDisplay = memorize('expected', prettyFormat(a, formatOptions)) |
| 245 | const bDisplay = memorize('actual', prettyFormat(b, formatOptions)) |
| 246 | |
| 247 | return diffLinesUnified2( |
| 248 | aDisplay.split('\n'), |
| 249 | bDisplay.split('\n'), |
| 250 | aCompare.split('\n'), |
| 251 | bCompare.split('\n'), |
| 252 | options, |
| 253 | ) |
| 254 | } |
| 255 | } |
| 256 | |
| 257 | const MAX_DIFF_STRING_LENGTH = 20_000 |
| 258 |
no test coverage detected