Home / Companies / LocalStack / Blog / Post Details
Content Deep Dive

Running CDK Integration Tests Locally with LocalStack

Blog post from LocalStack

Post Details
Company
Date Published
Author
Harsh Mishra
Word Count
1,921
Company Posts That Month
6
Language
English
Hacker News Points
-
Summary

AWS CDK's integration testing framework, often overlooked by teams, includes the integ-runner CLI and @aws-cdk/integ-tests-alpha construct library, which allow for testing real infrastructure by deploying stacks, running assertions, and tearing down resources. However, deploying to real AWS accounts incurs costs and delays feedback. The framework can be configured to use LocalStack, an AWS service emulator, enabling tests to run locally without AWS credentials or expenses. An example application, a friend request microservice leveraging AWS CDK services such as Lambda, API Gateway, DynamoDB Streams, and SQS, demonstrates the integration tests. These tests differ from unit tests as they deploy infrastructure and verify end-to-end behavior. By setting specific environment variables, the integ-runner can redirect to LocalStack, allowing developers to test complex event-driven pipelines with faster feedback. This setup involves deploying stacks to LocalStack, executing assertions on emulated services, and inspecting resources post-test. The framework ensures comprehensive testing of asynchronous state changes that unit tests may miss, providing an efficient and cost-effective solution for AWS CDK application testing.

Trends Found in this Post
Trend Post Mentions Total Month Mentions Posts Companies MoM
Serverless 15 1,011 235 82 -44%