@aws-cdk_integ-tests-alpha.IDeployAssert

interface IDeployAssert ๐Ÿ”น

LanguageType name
.NETAmazon.CDK.IntegTests.Alpha.IDeployAssert
Gogithub.com/aws/aws-cdk-go/awscdkintegtestsalpha/v2#IDeployAssert
Javasoftware.amazon.awscdk.integtests.alpha.IDeployAssert
Pythonaws_cdk.integ_tests_alpha.IDeployAssert
TypeScript (source)@aws-cdk/integ-tests-alpha ยป IDeployAssert

Interface that allows for registering a list of assertions that should be performed on a construct.

This is only necessary when writing integration tests.

Methods

NameDescription
awsApiCall(service, api, parameters?, outputPaths?)๐Ÿ”นQuery AWS using JavaScript SDK V2 API calls.
expect(id, expected, actual)๐Ÿ”นAssert that the ExpectedResult is equal to the ActualResult.
httpApiCall(url, options?)๐Ÿ”นMake an HTTP call to the provided endpoint.
invokeFunction(props)๐Ÿ”นInvoke a lambda function and return the response which can be asserted.

awsApiCall(service, api, parameters?, outputPaths?)๐Ÿ”น

public awsApiCall(service: string, api: string, parameters?: any, outputPaths?: string[]): IApiCall

Parameters

  • service string
  • api string
  • parameters any
  • outputPaths string[]

Returns

  • IApiCall

Query AWS using JavaScript SDK V2 API calls.

This can be used to either trigger an action or to return a result that can then be asserted against an expected value 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' }],
}));

expect(id, expected, actual)๐Ÿ”น

public expect(id: string, expected: ExpectedResult, actual: ActualResult): void

Parameters

  • id string
  • expected ExpectedResult
  • actual ActualResult

Assert that the ExpectedResult is equal to the ActualResult. Example

declare const integ: IntegTest;
declare const apiCall: AwsApiCall;
integ.assertions.expect(
  'invoke',
  ExpectedResult.objectLike({ Payload: 'OK' }),
  ActualResult.fromAwsApiCall(apiCall, 'Body'),
);

httpApiCall(url, options?)๐Ÿ”น

public httpApiCall(url: string, options?: FetchOptions): IApiCall

Parameters

  • url string
  • options FetchOptions

Returns

  • IApiCall

Make an HTTP call to the provided endpoint. Example

declare const app: App;
declare const integ: IntegTest;
const call = integ.assertions.httpApiCall('https://example.com/test');
call.expect(ExpectedResult.objectLike({
  Message: 'Hello World!',
}));

invokeFunction(props)๐Ÿ”น

public invokeFunction(props: LambdaInvokeFunctionProps): IApiCall

Parameters

  • props LambdaInvokeFunctionProps

Returns

  • IApiCall

Invoke a lambda function and return the response which can be asserted. Example

declare const app: App;
declare const integ: IntegTest;
const invoke = integ.assertions.invokeFunction({
  functionName: 'my-function',
});
invoke.expect(ExpectedResult.objectLike({
  Payload: '200',
}));