Create the test directory at tests/integration/<test-name>/ with these
files. The project runs CDK apps via Node 24 type-stripping (node bin/app.ts),
so the fixture is ESM ("type": "module") and imports carry the .ts
extension — there is NO ts-node / tsx dependency.
cdk.json:
{
"app": "node bin/app.ts"
}
package.json (note "type": "module"; no ts-node):
{
"name": "cdkd-integ-<test-name>",
"version": "1.0.0",
"private": true,
"description": "<one-line description>",
"scripts": {
"build": "tsc",
"watch": "tsc -w"
},
"devDependencies": {
"@types/node": "^20.0.0",
"aws-cdk": "^2.1112.0",
"typescript": "^5.0.0"
},
"dependencies": {
"aws-cdk-lib": "^2.169.0",
"constructs": "^10.0.0"
},
"type": "module"
}
tsconfig.json (ESNext / NodeNext, with rewriteRelativeImportExtensions
so the .ts-suffixed relative imports type-check):
{
"compilerOptions": {
"target": "ESNext",
"module": "NodeNext",
"lib": ["ES2023"],
"declaration": true,
"strict": true,
"noImplicitAny": true,
"strictNullChecks": true,
"noImplicitThis": true,
"alwaysStrict": true,
"noUnusedLocals": false,
"noUnusedParameters": false,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": false,
"inlineSourceMap": true,
"inlineSources": true,
"experimentalDecorators": true,
"strictPropertyInitialization": false,
"typeRoots": ["./node_modules/@types"],
"moduleResolution": "NodeNext",
"rewriteRelativeImportExtensions": true,
"erasableSyntaxOnly": true,
"verbatimModuleSyntax": true
},
"exclude": ["node_modules", "cdk.out"]
}
bin/app.ts — entry point. Import the stack WITH the .ts extension and
wire the env from CDK_DEFAULT_ACCOUNT / CDK_DEFAULT_REGION:
#!/usr/bin/env node
import * as cdk from 'aws-cdk-lib';
import { MyTestStack } from '../lib/<test-name>-stack.ts';
const app = new cdk.App();
new MyTestStack(app, 'Cdkd<PascalCaseName>Example', {
description: '<one-line description>',
env: {
account: process.env.CDK_DEFAULT_ACCOUNT,
region: process.env.CDK_DEFAULT_REGION,
},
});
lib/<test-name>-stack.ts — the stack. Keep it minimal: only the resource
under test + its required dependencies. In the class docstring, add a
covers: AWS::Service::Type line for each resource type the test is meant to
cover (the coverage matrix in step 7 parses these annotations).