From a7d73d842cb5bfcc8492d9778dac5527dc740f4c Mon Sep 17 00:00:00 2001 From: tstephen-nhs <231503406+tstephen-nhs@users.noreply.github.com> Date: Fri, 10 Apr 2026 13:23:15 +0000 Subject: [PATCH 1/3] docs: suggestions after cdk work --- .../instructions/languages/cdk.instructions.md | 17 +++++++++++++++++ .../languages/typescript.instructions.md | 2 ++ 2 files changed, 19 insertions(+) diff --git a/.github/instructions/languages/cdk.instructions.md b/.github/instructions/languages/cdk.instructions.md index b441a02..7924c2b 100644 --- a/.github/instructions/languages/cdk.instructions.md +++ b/.github/instructions/languages/cdk.instructions.md @@ -88,11 +88,28 @@ export class CptsApiAppStack extends Stack { - Prefer VPC endpoints for private connectivity - Minimize resource creation in test environments +## Unit Testing + +- Write unit tests for CDK stacks and constructs using synthesis-based assertions. +- Prefer in-process tests that instantiate CDK `App` and `Stack` objects directly and assert on synthesized templates. +- Keep assertions light-touch and stable, such as resource counts and a small number of important properties. +- Use smoke tests for `bin/` entrypoints only to verify the app can be synthesized from its CLI wiring and environment configuration. +- Avoid mocking AWS resources or writing tests that attempt to exercise live AWS behaviour. +- CDK constructs suitable for reuse should be placed in `eps-cdk-utils` repo. +- Smaller CDK constructs may be included here and should have tests associated. +- Do not test AWS implementation details owned by the CDK library. Test the resources and properties your code is responsible for declaring. + +### Recommended Test Styles + +- Smoke tests for `bin/` files: execute the entrypoint and assert that synthesis completes without throwing. +- In-process synth tests for stacks and constructs: instantiate the stack directly and assert resource counts or key CloudFormation properties with `Template.fromStack(...)`. + ## Validation and Verification - Build: `make cdk-synth` - Lint: `npm run lint --workspace packages/cdk` +- Test: `npm test --workspace packages/cdk` ## Maintenance diff --git a/.github/instructions/languages/typescript.instructions.md b/.github/instructions/languages/typescript.instructions.md index 4c15f42..beddb89 100644 --- a/.github/instructions/languages/typescript.instructions.md +++ b/.github/instructions/languages/typescript.instructions.md @@ -23,6 +23,7 @@ This document provides instructions for generating, reviewing, and maintaining T - Use destructuring for objects and arrays to improve readability. - Avoid magic numbers and hardcoded values; use named constants. - Keep functions pure and side-effect free when possible. +- Do not use the `void` operator to silence unused-value warnings; prefer code that makes usage explicit. ## Code Standards @@ -92,6 +93,7 @@ This document provides instructions for generating, reviewing, and maintaining T ### Type Safety - Prefer interfaces and types. You MUST NOT use `any`. +- Prefer `Array` over `T[]` for array type annotations. - Use type guards and assertions when necessary. - Example: From e040551236d18c9899bd0a4053de90d82bf1227f Mon Sep 17 00:00:00 2001 From: tstephen-nhs <231503406+tstephen-nhs@users.noreply.github.com> Date: Mon, 13 Apr 2026 12:23:17 +0100 Subject: [PATCH 2/3] docs: suggestions after cdk work --- .github/instructions/languages/cdk.instructions.md | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/instructions/languages/cdk.instructions.md b/.github/instructions/languages/cdk.instructions.md index 7924c2b..13bbd76 100644 --- a/.github/instructions/languages/cdk.instructions.md +++ b/.github/instructions/languages/cdk.instructions.md @@ -93,7 +93,6 @@ export class CptsApiAppStack extends Stack { - Write unit tests for CDK stacks and constructs using synthesis-based assertions. - Prefer in-process tests that instantiate CDK `App` and `Stack` objects directly and assert on synthesized templates. - Keep assertions light-touch and stable, such as resource counts and a small number of important properties. -- Use smoke tests for `bin/` entrypoints only to verify the app can be synthesized from its CLI wiring and environment configuration. - Avoid mocking AWS resources or writing tests that attempt to exercise live AWS behaviour. - CDK constructs suitable for reuse should be placed in `eps-cdk-utils` repo. - Smaller CDK constructs may be included here and should have tests associated. From e23fbe9b15d3587f6486489c5482ad4138a82325 Mon Sep 17 00:00:00 2001 From: tstephen-nhs <231503406+tstephen-nhs@users.noreply.github.com> Date: Mon, 13 Apr 2026 12:25:08 +0100 Subject: [PATCH 3/3] docs: tweak --- .github/instructions/languages/cdk.instructions.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/instructions/languages/cdk.instructions.md b/.github/instructions/languages/cdk.instructions.md index 13bbd76..3590eb8 100644 --- a/.github/instructions/languages/cdk.instructions.md +++ b/.github/instructions/languages/cdk.instructions.md @@ -94,8 +94,8 @@ export class CptsApiAppStack extends Stack { - Prefer in-process tests that instantiate CDK `App` and `Stack` objects directly and assert on synthesized templates. - Keep assertions light-touch and stable, such as resource counts and a small number of important properties. - Avoid mocking AWS resources or writing tests that attempt to exercise live AWS behaviour. -- CDK constructs suitable for reuse should be placed in `eps-cdk-utils` repo. -- Smaller CDK constructs may be included here and should have tests associated. +- CDK constructs suitable for reuse should be placed in `eps-cdk-utils` repo. +- Smaller CDK constructs may be included here and should have associated tests. - Do not test AWS implementation details owned by the CDK library. Test the resources and properties your code is responsible for declaring. ### Recommended Test Styles