Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(cloudformation-diff): format test #30509

Closed
wants to merge 2 commits into from

Commits on Jun 16, 2024

  1. 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]
    ```
    Chakshu Gupta authored and ChakshuGupta13 committed Jun 16, 2024
    Configuration menu
    Copy the full SHA
    21eb65d View commit details
    Browse the repository at this point in the history

Commits on Jul 2, 2024

  1. Configuration menu
    Copy the full SHA
    d42f2e7 View commit details
    Browse the repository at this point in the history