class Matcher
Language | Type name |
---|---|
.NET | Amazon.CDK.Assertions.Matcher |
Go | github.com/aws/aws-cdk-go/awscdk/v2/assertions#Matcher |
Java | software.amazon.awscdk.assertions.Matcher |
Python | aws_cdk.assertions.Matcher |
TypeScript (source) | aws-cdk-lib » assertions » Matcher |
Implemented by
Capture
Obtainable from
Match
.absent()
, Match
.anyValue()
, Match
.arrayEquals()
, Match
.arrayWith()
, Match
.exact()
, Match
.not()
, Match
.objectEquals()
, Match
.objectLike()
, Match
.serializedJson()
, Match
.stringLikeRegexp()
Represents a matcher that can perform special data matching capabilities between a given pattern and a target.
Example
// Given a template -
// {
// "Resources": {
// "MyBar": {
// "Type": "Foo::Bar",
// "Properties": {
// "Fred": {
// "Wobble": ["Flob", "Flib"],
// }
// }
// }
// }
// }
// The following will NOT throw an assertion error
template.hasResourceProperties('Foo::Bar', {
Fred: {
Wobble: [ Match.anyValue(), Match.anyValue() ],
},
});
// The following will throw an assertion error
template.hasResourceProperties('Foo::Bar', {
Fred: {
Wimble: Match.anyValue(),
},
});
Initializer
new Matcher()
Properties
Name | Type | Description |
---|---|---|
name | string | A name for the matcher. |
name
Type:
string
A name for the matcher.
This is collected as part of the result and may be presented to the user.
Methods
Name | Description |
---|---|
test(actual) | Test whether a target matches the provided pattern. |
static is | Check whether the provided object is a subtype of the IMatcher . |
test(actual)
public test(actual: any): MatchResult
Parameters
- actual
any
— the target to match.
Returns
Test whether a target matches the provided pattern.
Every Matcher must implement this method. This method will be invoked by the assertions framework. Do not call this method directly.
Matcher(x)
static ispublic static isMatcher(x: any): boolean
Parameters
- x
any
Returns
boolean
Check whether the provided object is a subtype of the IMatcher
.