class ExpectedResult
Language | Type name |
---|---|
![]() | Amazon.CDK.IntegTests.Alpha.ExpectedResult |
![]() | github.com/aws/aws-cdk-go/awscdkintegtestsalpha/v2#ExpectedResult |
![]() | software.amazon.awscdk.integtests.alpha.ExpectedResult |
![]() | aws_cdk.integ_tests_alpha.ExpectedResult |
![]() | @aws-cdk/integ-tests-alpha ยป ExpectedResult |
Represents the "expected" results to compare.
Example
declare const app: App;
declare const stack: Stack;
declare const queue: sqs.Queue;
declare const fn: lambda.IFunction;
const integ = new IntegTest(app, 'Integ', {
testCases: [stack],
});
integ.assertions.invokeFunction({
functionName: fn.functionName,
invocationType: InvocationType.EVENT,
payload: JSON.stringify({ status: 'OK' }),
});
const message = integ.assertions.awsApiCall('SQS', 'receiveMessage', {
QueueUrl: queue.queueUrl,
WaitTimeSeconds: 20,
});
message.assertAtPath('Messages.0.Body', ExpectedResult.objectLike({
requestContext: {
condition: 'Success',
},
requestPayload: {
status: 'OK',
},
responseContext: {
statusCode: 200,
},
responsePayload: 'success',
}));
Initializer
new ExpectedResult()
Properties
Name | Type | Description |
---|---|---|
result | string | The expected results encoded as a string. |
result
Type:
string
The expected results encoded as a string.
Methods
Name | Description |
---|---|
static array | The actual results must be a list and must contain an item with the expected results. |
static exact(expected) | The actual results must match exactly. |
static object | The expected results must be a subset of the actual results. |
static string | Actual results is a string that matches the Expected result regex. |
static arrayWith(expected)
public static arrayWith(expected: any[]): ExpectedResult
Parameters
- expected
any[]
Returns
The actual results must be a list and must contain an item with the expected results.
See also: https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.assertions.Match.html#static-arraywbrwithpattern Example
// actual results
const actual = [
{
stringParam: 'hello',
},
{
stringParam: 'world',
},
];
// pass
ExpectedResult.arrayWith([
{
stringParam: 'hello',
},
]);
static exact(expected)
public static exact(expected: any): ExpectedResult
Parameters
- expected
any
Returns
The actual results must match exactly.
Missing data will result in a failure
See also: https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.assertions.Match.html#static-exactpattern Example
// actual results
const actual = {
stringParam: 'hello',
numberParam: 3,
booleanParam: true,
};
// pass
ExpectedResult.exact({
stringParam: 'hello',
numberParam: 3,
booleanParam: true,
})
// fail
ExpectedResult.exact({
stringParam: 'hello',
});
static objectLike(expected)
public static objectLike(expected: { [string]: any }): ExpectedResult
Parameters
- expected
{ [string]: any }
Returns
The expected results must be a subset of the actual results.
See also: https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.assertions.Match.html#static-objectwbrlikepattern Example
// actual results
const actual = {
stringParam: 'hello',
numberParam: 3,
booleanParam: true,
objectParam: { prop1: 'value', prop2: 'value' },
};
// pass
ExpectedResult.objectLike({
stringParam: 'hello',
objectParam: { prop1: 'value' },
});
static stringLikeRegexp(expected)
public static stringLikeRegexp(expected: string): ExpectedResult
Parameters
- expected
string
Returns
Actual results is a string that matches the Expected result regex.
See also: https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.assertions.Match.html#static-stringwbrlikewbrregexppattern Example
// actual results
const actual = 'some string value';
// pass
ExpectedResult.stringLikeRegexp('value');