Add Jest and CDK unit tests with CI integration#30
Merged
bermannoah merged 3 commits intomasterfrom Mar 16, 2026
Merged
Conversation
- @aws-cdk/assert: 1.204.0 (CDK v1 assertion library) - jest: 27.5.1 - ts-jest: 27.1.5 - @types/jest: 27.5.2 - Add "test": "jest" script to package.json Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Downgrade @aws-cdk/assert to 1.75.0 to match CDK package versions - Write 12 tests covering: Lambda runtime/count, DynamoDB config, SQS queues and DLQ wiring, Step Functions machines, API Gateway resources when enableAPI is true/false, SNS topic subscription, and asset-path validation - Add "npm test" step to the js-build CI job Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@aws-cdk/assert@1.75.0 requires jest ^26.6.3 and is incompatible with the 1.204.0 assert library at the CDK 1.75.0 construct level (circular JSON errors). Pinning jest/ts-jest/@types/jest to 26.x satisfies the peer dep and allows npm ci to run without --legacy-peer-deps. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a Jest-based unit test suite for the CDK DeepAlertStack and wires it into CI so the stack’s synthesized CloudFormation resources are validated on every PR.
Changes:
- Replaces the previous placeholder/disabled CDK test with a comprehensive Jest suite covering Lambdas, DynamoDB, SQS, Step Functions, API Gateway (optional), SNS subscription (optional), and asset-path validation.
- Adds Jest/ts-jest + CDK assert tooling and a
npm testscript. - Updates the GitHub Actions workflow to execute the JS test suite in CI.
Reviewed changes
Copilot reviewed 3 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
test/stack/deepalert.test.ts |
Adds Jest unit tests that synthesize DeepAlertStack and assert expected AWS resources/configuration, including test-time stub assets. |
package.json |
Adds Jest tooling dependencies and a test script to run the new suite. |
.github/workflows/test.yml |
Runs npm test in the existing JS build job to enforce the new tests in CI. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request introduces automated testing for the CDK stack using Jest and the AWS CDK assert library. It sets up a comprehensive test suite for the
DeepAlertStack, verifies resource creation and configuration, and integrates these tests into the GitHub Actions workflow. Additionally, it updates dependencies and scripts to support the new testing setup.Testing infrastructure and test suite:
test/stack/deepalert.test.tsto verify that the CDK stack creates the expected AWS resources (Lambda functions, DynamoDB tables, SQS queues, Step Functions, and optionally API Gateway and SNS subscriptions) and validates asset paths.Build and test automation:
testscript topackage.jsonand integrates Jest-related dependencies (jest,ts-jest,@types/jest) and AWS CDK assert tools for testing. [1] [2].github/workflows/test.yml) to run the test suite as part of CI.