class ExpectedResult
Language | Type name |
---|---|
.NET | Amazon.CDK.IntegTests.ExpectedResult |
Java | software.amazon.awscdk.integtests.ExpectedResult |
Python | aws_cdk.integ_tests.ExpectedResult |
TypeScript (source) | @aws-cdk/integ-tests » ExpectedResult |
Represents the "expected" results to compare.
Example
declare const app: App;
declare const integ: IntegTest;
integ.assertions.awsApiCall('SQS', 'sendMessage', {
QueueUrl: 'url',
MessageBody: 'hello',
});
const message = integ.assertions.awsApiCall('SQS', 'receiveMessage', {
QueueUrl: 'url',
});
message.expect(ExpectedResult.objectLike({
Messages: [{ Body: 'hello' }],
}));
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. |
With(expected)
static arraypublic 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. 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 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',
});
Like(expected)
static objectpublic static objectLike(expected: { [string]: any }): ExpectedResult
Parameters
- expected
{ [string]: any }
Returns
The expected results must be a subset of the actual results. Example
// actual results
const actual = {
stringParam: 'hello',
numberParam: 3,
booleanParam: true,
};
// pass
ExpectedResult.objectLike({
stringParam: 'hello',
});
LikeRegexp(expected)
static stringpublic static stringLikeRegexp(expected: string): ExpectedResult
Parameters
- expected
string
Returns
Actual results is a string that matches the Expected result regex. Example
// actual results
const actual = 'some string value';
// pass
ExpectedResult.stringLikeRegexp('value');