fix(cdk): optimize test suite via shared CDK template synthesis#195
Draft
scottschreckengaust wants to merge 2 commits into
Draft
fix(cdk): optimize test suite via shared CDK template synthesis#195scottschreckengaust wants to merge 2 commits into
scottschreckengaust wants to merge 2 commits into
Conversation
Refactors task-api.test.ts to synthesize CDK templates once per describe block via beforeAll instead of per-test. Reduces CDK synth calls from 41 to 11 while preserving all 40 test assertions unchanged. Before: 371s total Jest / task-api.test 370s wall clock After: 145s total Jest / task-api.test 89s wall clock Closes #194 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
3c2cf9e to
97fae4e
Compare
5 tasks
Applies the same beforeAll template-sharing pattern to: - task-orchestrator.test.ts: 33 → 12 synths (4 shared + 8 unique) - ecs-agent-cluster.test.ts: 10 → 2 synths (1 shared + 1 unique) Combined with task-api.test.ts, total CDK synths across the three heaviest suites drop from 84 to 25 (70% fewer). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
8 tasks
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.
Summary
beforeAllFiles optimized
task-api.test.tstask-orchestrator.test.tsecs-agent-cluster.test.tsWhy this works
CDK
Template.fromStack()is the expensive operation in construct tests — it synthesizes the full CloudFormation template. The original code called it in everytest()block even when the config was identical. SinceTemplateobjects are read-only (assertions don't mutate them), tests with the same input safely share a single synthesized template.Tests requiring unique configurations (custom props, overrides) still synthesize inline.
Test plan
beforeAllCloses #194
🤖 Generated with Claude Code
Co-Authored-By: Claude Opus 4.6 (1M context) noreply@anthropic.com