-
Notifications
You must be signed in to change notification settings - Fork 4k
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
feat(assertions): improve printing of match failures #23453
Conversation
Debugging match failures with the `assertions` library used to be a bit frustrating. The library used to guess the single closest matching resource and print it fully, with a list of match failures underneath. This has two problems: - Matching the failures up to the data structure requires a lot of scanning back and forth between different screen lines. - The library could incorrectly guess at the closest match, giving you useless information. This change is a first (and by no means the last) stab at improving the situation: - Mismatch errors are printed in-line with the data structure, making it very clear what they are referencing (removing the need for scanning). - Fields in complex data structures that aren't involved in the mismatch at all are collapsed. For example, a complex subobject that matches be printed as `{ ... }` so it doesn't take up too much vertical space. - Because we now have a lot of vertical space left, we can print the N closest matches, lowering the chance that we guess wrong and leave you without information to correct the test. The last point can probably be improved more in the future, by coming up with a more accurate metric for "closest match" than "failure count", but this will do for now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The pull request linter has failed. See the aws-cdk-automation comment below for failure reasons. If you believe this pull request should receive an exemption, please comment and provide a justification.
✅ Updated pull request passes all PRLinter validations. Dissmissing previous PRLinter review.
Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
Debugging match failures with the `assertions` library used to be a bit frustrating. The library used to guess the single closest matching resource and print it fully, with a list of match failures underneath. This has two problems: - Matching the failures up to the data structure requires a lot of scanning back and forth between different screen lines. - The library could incorrectly guess at the closest match, giving you useless information. This change is a first (and by no means the last) stab at improving the situation: - Mismatch errors are printed in-line with the data structure, making it very clear what they are referencing (removing the need for scanning). - Fields in complex data structures that aren't involved in the mismatch at all are collapsed. For example, a complex subobject that matches be printed as `{ ... }` so it doesn't take up too much vertical space. - Because we now have a lot of vertical space left, we can print the N closest matches, lowering the chance that we guess wrong and leave you without information to correct the test. The last point can probably be improved more in the future, by coming up with a more accurate metric for "closest match" than "failure count", but this will do for now. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Debugging match failures with the `assertions` library used to be a bit frustrating. The library used to guess the single closest matching resource and print it fully, with a list of match failures underneath. This has two problems: - Matching the failures up to the data structure requires a lot of scanning back and forth between different screen lines. - The library could incorrectly guess at the closest match, giving you useless information. This change is a first (and by no means the last) stab at improving the situation: - Mismatch errors are printed in-line with the data structure, making it very clear what they are referencing (removing the need for scanning). - Fields in complex data structures that aren't involved in the mismatch at all are collapsed. For example, a complex subobject that matches be printed as `{ ... }` so it doesn't take up too much vertical space. - Because we now have a lot of vertical space left, we can print the N closest matches, lowering the chance that we guess wrong and leave you without information to correct the test. The last point can probably be improved more in the future, by coming up with a more accurate metric for "closest match" than "failure count", but this will do for now. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Debugging match failures with the
assertions
library used to be a bit frustrating. The library used to guess the single closest matching resource and print it fully, with a list of match failures underneath.This has two problems:
This change is a first (and by no means the last) stab at improving the situation:
{ ... }
so it doesn't take up too much vertical space.The last point can probably be improved more in the future, by coming up with a more accurate metric for "closest match" than "failure count", but this will do for now.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license