Example
import { Template, Capture } from "aws-cdk-lib/assertions"; // import assertions
import * as lambda from "aws-cdk-lib/aws-lambda";
import * as cdk from "aws-cdk-lib";
import { HitCounter } from "../lib/hitcounter";
test('DynamoDB Table Created', () => {
const stack = new cdk.Stack(); // create a stack
new HitCounter(stack, 'MyTestConstruct', {
downstream: new lambda.Function(stack, 'TestFunction', {
runtime: lambda.Runtime.NODEJS_16_X,
handler: 'main.handler',
code: lambda.Code.fromAsset('lambda'),
})
}); // add the HitCounter to the stack
const template = Template.fromStack(stack); // create a mock template
template.resourceCountIs("AWS::DynamoDB::Table", 1); // assert
})