Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save exoego/ddd68273097093ed4831a9219ad55307 to your computer and use it in GitHub Desktop.
Save exoego/ddd68273097093ed4831a9219ad55307 to your computer and use it in GitHub Desktop.
How to ignore AWS::Lambda::Version with jest-cdk-snapshot
import * as cdk from "aws-cdk-lib";
export function getSubsetResourceTypes(stack: cdk.Stack): string[] {
const subResources = stack.node.children.map((child) => child.node.defaultChild as unknown as cdk.CfnResource | undefined);
return subResources.map((sub) => sub?.cfnResourceType).filter((t) => t !== undefined) as string[];
}
expect(lambdaStack).toMatchCdkSnapshot({
ignoreAssets: true,
subsetResourceTypes: getSubsetResourceTypes(stack.lambda).filter((t) => t !== "AWS::Lambda::Version"),
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment