Skip to content

Add Jest and CDK unit tests with CI integration#30

Merged
bermannoah merged 3 commits intomasterfrom
nb/update-js-deps
Mar 16, 2026
Merged

Add Jest and CDK unit tests with CI integration#30
bermannoah merged 3 commits intomasterfrom
nb/update-js-deps

Conversation

@bermannoah
Copy link
Contributor

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:

  • Adds Jest-based test suite in test/stack/deepalert.test.ts to 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.
  • Sets up temporary directories and stub files to properly simulate Lambda asset directories during tests.

Build and test automation:

  • Adds a test script to package.json and integrates Jest-related dependencies (jest, ts-jest, @types/jest) and AWS CDK assert tools for testing. [1] [2]
  • Updates the GitHub Actions workflow (.github/workflows/test.yml) to run the test suite as part of CI.

bermannoah and others added 3 commits March 16, 2026 11:33
- @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>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 test script.
  • 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.

@bermannoah bermannoah marked this pull request as ready for review March 16, 2026 20:16
@bermannoah bermannoah merged commit 02f475e into master Mar 16, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants