| 25 | toMatchWithDiff: () => { |
| 26 | return { |
| 27 | compare(actual: string, expected: string) { |
| 28 | actual = dedent`${actual}`; |
| 29 | expected = dedent`${expected}`; |
| 30 | |
| 31 | if (actual === expected) { |
| 32 | return {pass: true}; |
| 33 | } |
| 34 | |
| 35 | const diffWithColors = diffText(expected, actual); |
| 36 | return { |
| 37 | pass: false, |
| 38 | message: |
| 39 | `${chalk.bold('Expected contents to match.')}\n\n` + |
| 40 | ` - ${chalk.green('■■■■■■■')}: Unexpected text in your test assertion.\n` + |
| 41 | ` - ${chalk.red(`■■■■■■■`)}: Text that is missing in your assertion.\n` + |
| 42 | `${chalk.bold('Diff below')}:\n${diffWithColors}`, |
| 43 | }; |
| 44 | }, |
| 45 | }; |
| 46 | }, |
| 47 | }); |