Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(cloudformation-diff): format test
- Currently, `yarn build` fails in '@aws-cdk-testing' package with following error because 'Received' string is formatted with `chalk.red` and 'Expected' string is by default formatted with `chalk.green`: ``` ✖ @aws-cdk/cloudformation-diff:test $ cdk-test FAIL test/format.test.ts ● format value can handle partial json strings expect(received).toEqual(expected) // deep equality Expected: "{\"nice\":\"great\",\"partialJson\":\"{\\\"wow\\\": \\\"great\"}" Received: "{\"nice\":\"great\",\"partialJson\":\"{\\\"wow\\\": \\\"great\"}" 6 | test('format value can handle partial json strings', () => { 7 | const output = formatter.formatValue({ nice: 'great', partialJson: '{"wow": "great' }, chalk.red); > 8 | expect(output).toEqual('{\"nice\":\"great\",\"partialJson\":\"{\\\"wow\\\": \\\"great\"}'); | ^ 9 | }); at Object.<anonymous> (test/format.test.ts:8:18) ``` - But as unit-test aims to test equality of strings in terms of content instead of color formatting, hence, it is better to utilise `toMatch` instead of `toEqual`. - Upon retesting, unit-test passed: ``` ✔ @aws-cdk/cloudformation-diff:build [local cache] ```
- Loading branch information