Skip to content

Commit a7d73d8

Browse files
committed
docs: suggestions after cdk work
1 parent 8b4d7f5 commit a7d73d8

2 files changed

Lines changed: 19 additions & 0 deletions

File tree

.github/instructions/languages/cdk.instructions.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,28 @@ export class CptsApiAppStack extends Stack {
8888
- Prefer VPC endpoints for private connectivity
8989
- Minimize resource creation in test environments
9090

91+
## Unit Testing
92+
93+
- Write unit tests for CDK stacks and constructs using synthesis-based assertions.
94+
- Prefer in-process tests that instantiate CDK `App` and `Stack` objects directly and assert on synthesized templates.
95+
- Keep assertions light-touch and stable, such as resource counts and a small number of important properties.
96+
- Use smoke tests for `bin/` entrypoints only to verify the app can be synthesized from its CLI wiring and environment configuration.
97+
- Avoid mocking AWS resources or writing tests that attempt to exercise live AWS behaviour.
98+
- CDK constructs suitable for reuse should be placed in `eps-cdk-utils` repo.
99+
- Smaller CDK constructs may be included here and should have tests associated.
100+
- Do not test AWS implementation details owned by the CDK library. Test the resources and properties your code is responsible for declaring.
101+
102+
### Recommended Test Styles
103+
104+
- Smoke tests for `bin/` files: execute the entrypoint and assert that synthesis completes without throwing.
105+
- In-process synth tests for stacks and constructs: instantiate the stack directly and assert resource counts or key CloudFormation properties with `Template.fromStack(...)`.
106+
91107

92108
## Validation and Verification
93109

94110
- Build: `make cdk-synth`
95111
- Lint: `npm run lint --workspace packages/cdk`
112+
- Test: `npm test --workspace packages/cdk`
96113

97114
## Maintenance
98115

.github/instructions/languages/typescript.instructions.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ This document provides instructions for generating, reviewing, and maintaining T
2323
- Use destructuring for objects and arrays to improve readability.
2424
- Avoid magic numbers and hardcoded values; use named constants.
2525
- Keep functions pure and side-effect free when possible.
26+
- Do not use the `void` operator to silence unused-value warnings; prefer code that makes usage explicit.
2627

2728
## Code Standards
2829

@@ -92,6 +93,7 @@ This document provides instructions for generating, reviewing, and maintaining T
9293
### Type Safety
9394

9495
- Prefer interfaces and types. You MUST NOT use `any`.
96+
- Prefer `Array<T>` over `T[]` for array type annotations.
9597
- Use type guards and assertions when necessary.
9698
- Example:
9799

0 commit comments

Comments
 (0)