@andybalham/cdk-cloud-test-kit
TypeScript icon, indicating that this package has built-in type declarations

2.0.2 • Public • Published

CDK Cloud Test Kit

CDK Cloud Test Kit logo

The CDK Cloud Test Kit is a set of TypeScript classes, with the aim of making it straightforward to test CDK constructs in the cloud.

The approach is based on two key classes:

  • IntegrationTestStack - A base Stack, used to deploy the construct under test along with any test drivers and test observers.
  • IntegrationTestClient - A class that is used to drive the construct under test and to poll for the resulting test observations.

Overview of package classes

IntegrationTestStack is an abstract class, derived from the CDK Stack class, that provides the following functionality:

  • Easy deployment of common test resource scaffolding, such as observer Lambda functions and a DynamoDB table for recording observations.
  • A method to tag the deployed resources, so that they can be discovered, invoked, and read without needing to know the resource names or ARNs.

IntegrationTestClient is a class that works in conjunction with the IntegrationTestStack that provides the following functionality:

  • A set of methods to locate and interact with the deployed test resources using the AWS SDK. For example, to upload an object to an S3 bucket or publish an event to an SNS topic.
  • A method to poll for test observations, making writing asynchronous unit tests simple and clear.

The best way to see what the cdk-cloud-test-kit can do for you is to look at the examples or, better still, run them.

Examples

Simple Event Router

This example tests a construct that encapsulates a simple SNS event router. It demonstrates how the toolkit can publish test events and observe the effects to validate the behaviour.

Simple Message Router

This example is similar to the Simple Event Router, but uses SQS queues with DLQs instead of SNS topics. It demonstrates how the toolkit can be used to test error conditions with the use of mock Lambda function responses.

Loan Processor State Machine

This example demonstrates how the toolkit can be used to test step functions. It shows how the toolkit can be used to execute and monitor step functions and how it can be used to exercise all the step function branches with the use of mock responses. In addition, it demonstrates how the toolkit can be used to observe DynamoDB table events along with SQS queues and SNS topics.

Notification Hub

This example shows how the toolkit can be used to put events on an EventBridge event bus. It also shows how the toolkit can be used to test event patterns, both prior to deployment and also once the rules are deployed.

Request API

This example shows how the toolkit can be used to help invoke API Gateway instances and how it can be used to create custom observers that can be used to record any sort of observation you like.

Package Sidebar

Install

npm i @andybalham/cdk-cloud-test-kit

Weekly Downloads

2

Version

2.0.2

License

ISC

Unpacked Size

143 kB

Total Files

86

Last publish

Collaborators

  • andybalham