Skip to content
v2.274.0

Experimental

@aws-cdk/integ-tests-alpha is an experimental (alpha) package: its API may change in any release, without a major version bump.

ExpectedResult Class ​

Represents the "expected" results to compare.

Example ​

ts
declare const app: App;
declare const stack: Stack;
declare const sm: IStateMachine;

const testCase = new IntegTest(app, 'IntegTest', {
  testCases: [stack],
});

// Start an execution
const start = testCase.assertions.awsApiCall('StepFunctions', 'startExecution', {
  stateMachineArn: sm.stateMachineArn,
});

// describe the results of the execution
const describe = testCase.assertions.awsApiCall('StepFunctions', 'describeExecution', {
  executionArn: start.getAttString('executionArn'),
});

// assert the results
describe.expect(ExpectedResult.objectLike({
  status: 'SUCCEEDED',
}));

Initializer ​

ts
new ExpectedResult()
python
ExpectedResult()
java
new ExpectedResult()
csharp
new ExpectedResult()
go
NewExpectedResult()

Properties ​

resultstringresultstrresultStringResultstringResult*stringrequired#
The expected results encoded as a string.

Methods ​

arrayWith(expected: any[]): ExpectedResult // chainable@staticmethod def array_with(expected: typing.List[Any]) -> ExpectedResultpublic static ExpectedResult arrayWith(List<Object> expected)public static ExpectedResult ArrayWith(object[] expected)func ArrayWith(Expected *[]interface{}) ExpectedResultstatic#
The actual results must be a list and must contain an item with the expected results.
example
ts
// actual results
const actual = [
  {
    stringParam: 'hello',
  },
  {
    stringParam: 'world',
  },
];
// pass
ExpectedResult.arrayWith([
  {
    stringParam: 'hello',
  },
]);
exact(expected: any): ExpectedResult // chainable@staticmethod def exact(expected: Any) -> ExpectedResultpublic static ExpectedResult exact(Object expected)public static ExpectedResult Exact(object expected)func Exact(Expected interface{}) ExpectedResultstatic#
The actual results must match exactly.

Missing data will result in a failure

example
ts
// actual results
const actual = {
  stringParam: 'hello',
  numberParam: 3,
  booleanParam: true,
};
// pass
ExpectedResult.exact({
  stringParam: 'hello',
  numberParam: 3,
  booleanParam: true,
})

// fail
ExpectedResult.exact({
  stringParam: 'hello',
});
objectLike(expected: { [key: string]: any }): ExpectedResult // chainable@staticmethod def object_like(expected: typing.Mapping[str, Any]) -> ExpectedResultpublic static ExpectedResult objectLike(Map<String, Object> expected)public static ExpectedResult ObjectLike(IDictionary<string, object> expected)func ObjectLike(Expected *map[string]interface{}) ExpectedResultstatic#
The expected results must be a subset of the actual results.
example
ts
// actual results
const actual = {
  stringParam: 'hello',
  numberParam: 3,
  booleanParam: true,
  objectParam: { prop1: 'value', prop2: 'value' },
};
// pass
ExpectedResult.objectLike({
  stringParam: 'hello',
  objectParam: { prop1: 'value' },
});
stringLikeRegexp(expected: string): ExpectedResult // chainable@staticmethod def string_like_regexp(expected: str) -> ExpectedResultpublic static ExpectedResult stringLikeRegexp(String expected)public static ExpectedResult StringLikeRegexp(string expected)func StringLikeRegexp(Expected *string) ExpectedResultstatic#
Actual results is a string that matches the Expected result regex.
example
ts
// actual results
const actual = 'some string value';

// pass
ExpectedResult.stringLikeRegexp('value');