feat(assertions): Add the hasNoXXX methods.#19330
Conversation
kaizencc
left a comment
There was a problem hiding this comment.
Thanks for submitting this @joe-king-sh! Can you add a line or two about these APIs in the README?
|
@kaizen3031593 |
kaizencc
left a comment
There was a problem hiding this comment.
Looks great @joe-king-sh! A few minor nits, along with changing the error message to be more descriptive.
| return; | ||
| } | ||
|
|
||
| return `Stack has ${Object.keys(result.matches).length} messages.`; |
There was a problem hiding this comment.
| return `Stack has ${Object.keys(result.matches).length} messages.`; | |
| return `Expected no matches, but stack has ${Object.keys(result.matches).length} messages.`; |
There was a problem hiding this comment.
In addition to the above change, I think we should also be returning the matched messages in the error message.
It's possible someone looks for annotations.hasNoError('/Default/Fred', Match.anyValue()) and they should be able to know what error message they are getting.
| }); | ||
|
|
||
| test('no match', () => { | ||
| expect(() => annotations.hasNoInfo('/Default/Qux', 'this is an info')).toThrowError(/Stack has 1 messages./); |
There was a problem hiding this comment.
| expect(() => annotations.hasNoInfo('/Default/Qux', 'this is an info')).toThrowError(/Stack has 1 messages./); | |
| expect(() => annotations.hasNoInfo('/Default/Qux', 'this is an info')) | |
| .toThrowError(/Stack has 1 messages./); |
| - `hasError()`, `findError()` and `hasNoError()` | ||
| - `hasWarning()`,`findWarning()` and `hasNoWarning()` | ||
| - `hasInfo()`, `findInfo()` and `hasNoInfo()` |
There was a problem hiding this comment.
| - `hasError()`, `findError()` and `hasNoError()` | |
| - `hasWarning()`,`findWarning()` and `hasNoWarning()` | |
| - `hasInfo()`, `findInfo()` and `hasNoInfo()` | |
| - `hasError()`, `hasNoError()`, and `findError()` | |
| - `hasWarning()`, `hasNoWarning()`, and `findWarning()` | |
| - `hasInfo()`, `hasNoInfo()`, and `findInfo()` |
|
@kaizen3031593 |
kaizencc
left a comment
There was a problem hiding this comment.
Looks great @joe-king-sh! I just added a bit of formatting to the error message.
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 master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
This PR adds
hasNoError,hasNoWarning, andhasNoInfomethods to the Annotations assertions toolkit.Fixes #18874
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license