macalbert/envilder/typescript-cdk-testing
Claude Code and agent skill by macalbert/envilder
- community
Checking that the SKILL.md file is still in the repository.
AWS CDK testing patterns including snapshot tests, fine-grained assertions with Template.fromStack(), and normalization strategies. Use when writing or reviewing CDK infrastructure tests.
Install
npx vskill@latest install macalbert/envilder/typescript-cdk-testingSKILL.md
CDK Testing Skill
Testing patterns for AWS CDK infrastructure in the Envilder project (src/iac/). Tests live in tests/iac/ and run with Vitest.
When to Use
- Writing tests for new CDK stacks or constructs
- Adding assertions for specific resource properties
- Updating snapshots after intentional infrastructure changes
- Reviewing CDK test coverage
Test Architecture
Test Organization
Tests mirror the source structure:
Snapshot Testing (Primary Pattern)
~80% of CDK tests use snapshot testing to detect unintended infrastructure drift:
Snapshot Normalization
Remove non-deterministic values before snapshotting:
Normalize these properties:
S3Key: Lambda deployment artifact hashSourceObjectKeys: Asset hashes- Any
Fn::Joinwith account-specific values
Updating Snapshots
When infrastructure changes are intentional:
Rules:
- Review snapshot diffs carefully before approving
- Never update snapshots to suppress failures: understand the change first
- Commit updated snapshots alongside the code that caused the change
Fine-Grained Assertions (Secondary Pattern)
~20% of tests verify specific resource properties:
Common Assertion Methods
| Method | Purpose | |
|---|---|---|
template.hasResourceProperties(type, props) | Resource exists with properties | |
template.hasResource(type, props) | Resource exists with full config | |
template.resourceCountIs(type, count) | Exact count of resource type | |
template.hasOutput(logicalId, props) | Stack output exists | |
Match.objectLike({...}) | Partial match on nested objects | |
Match.arrayWith([...]) | Array contains expected elements | |
Match.stringLikeRegexp(pattern) | String matches regex | |
Match.not(matcher) | Negation of any matcher | |
Match.absent() | Property should not exist |
When to Use Which Pattern
| Scenario | Pattern | |
|---|---|---|
| New stack or construct | Snapshot: captures full baseline | |
| Specific security property (e.g., encryption) | Assertion: explicit check won't be missed | |
| Resource count verification | Assertion: resourceCountIs | |
| Cross-resource references | Assertion: verify Ref/Fn::GetAtt | |
| Infrastructure refactor (same output) | Snapshot: confirms no drift | |
| Config-driven resource creation | Snapshot + assertion for critical properties |
Test Naming
Follow the project Should_{Behavior}_When_{Condition} convention:
Test Data: Config Objects
Use realistic config objects that match the config-driven infrastructure pattern:
Commands
Anti-Patterns
| Anti-Pattern | Correct Approach | |
|---|---|---|
| Snapshot without normalization | Normalize non-deterministic values (S3Key, hashes) | |
| Testing CDK internals (construct tree) | Test the synthesized CloudFormation template | |
| Hardcoded account/region in tests | Use test-specific App with mock env | |
| Updating snapshots without reviewing diff | Always review what changed and why | |
| Only snapshot tests for security-critical props | Add explicit assertions for encryption, IAM, SG rules |
Security
- Security scanPassed, 90 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryChecking.github/skills/typescript-cdk-testing/SKILL.md
Popularity
- Repository stars
- 135
- Repository forks
- 4
- 7-day trend score
- 25
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/macalbert/envilder/typescript-cdk-testing)