Version 1 of the AWS Cloud Development Kit (AWS CDK) is now in maintenance mode.
Refer to the AWS Cloud Development Kit (AWS CDK) v2 Learning Path for updated CDK v2 Labs and Challenges.
The AWS Cloud Development Kit can provide infrastructure engineers with the same predictability and repeatability seen in application code development. One way the AWS CDK achieves this is by incorporating the use of construct assertions with the popular Jest JavaScript testing framework. The AWS CDK Assert library contains helpers for writing tests to evaluate the CloudFormation templates that are generated by the CDK project. These testing modules, paired with the practical testing capabilities provided by Jest, allow developers to implement various types of tests including snapshot tests.
A CDK snapshot test begins by rendering an AWS CloudFormation template in JSON to be used as a reference snapshot. Whenever a snapshot test runs, a new template is generated and compared with the initial reference snapshot. If they do not match the test will fail, which can mean one of two things:
This type of testing is useful as you write your own CDK constructs and allows you to define expectations early on in development, and maintain those requirements as the application grows.
In this lab, you will discover how the Jest framework works within a CDK project and learn how to implement snapshot tests.
Upon completion of this intermediate-level lab, you will be able to:
Familiarity with the following will be beneficial:
The following labs can be used to fulfill the prerequisite: