I am trying to do some snapshot testing on my CDK stack but the snapshot is not generating.
This is my stack:
export interface SNSStackProps extends cdk.StackProps {
assumedRole: string
}
export class SNSStack extends cdk.Stack {
constructor(scope: cdk.Construct, id: string, props: AssumedRole) {
super(scope, id, props)
const topicName = "TopicName"
const topic = new sns.Topic(this, topicName, {
displayName: "Topic Name",
fifo: true,
topicName: topicName,
contentBasedDeduplication: true
})
const assumedRole = iam.Role.fromRoleArn(
this,
"AssumedRole",
props.assumedRole
)
topic.grantPublish(assumedRole.grantPrincipal)
}
}
This is my snapshot test
test("Creates an SNS topic ", () => {
const stack = new Stack()
new SNSStack.SNSStack(stack, "SNSStack", {
env: {
account: "test_account",
region: "test_region"
},
assumedRoleArn: "arn:aws:iam::1111111:role/testRole"
})
expect(SynthUtils.toCloudFormation(stack)).toMatchSnapshot()
})
This generates a snapshot with an empty object like this
exports[`dlq creates an alarm 1`] = `Object {}`;
Why is the object empty in the snapshot? And how do I get the Object in the snapshot to populate with the resources in my stack?