Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: avoid synthesizing the CDK stack in tests multiple times #190

Closed
mmalenic opened this issue Mar 28, 2024 · 3 comments · Fixed by #194
Closed

test: avoid synthesizing the CDK stack in tests multiple times #190

mmalenic opened this issue Mar 28, 2024 · 3 comments · Fixed by #194
Assignees
Labels
test an issue relating to tests

Comments

@mmalenic
Copy link
Member

mmalenic commented Mar 28, 2024

Ideally the cdk-nag tests should only have to synthesize the stack once, and base all assertions on the same stack after that. This would improve the speed at which the tests run, because it would avoid compiling code or bundling microservice assets multiple times.

@mmalenic mmalenic added feature New feature test an issue relating to tests and removed feature New feature labels Mar 28, 2024
@mmalenic
Copy link
Member Author

Context, I think Annotations.fromStack synthesizes the stack everytime, and most tests use this method, for example:

const errors = Annotations.fromStack(stack)
.findError('*', Match.stringLikeRegexp('AwsSolutions-.*'))
.map(synthesisMessageToString);
expect(errors).toHaveLength(0);

In aws-cdk-lib this leads to: https:/aws/aws-cdk/blob/69cff2eda84dacfe265d518fc88ccf55930f59c4/packages/aws-cdk-lib/assertions/lib/annotations.ts#L165

@williamputraintan
Copy link
Member

Ahh just realise, perhaps #194 fixes this?

@mmalenic
Copy link
Member Author

Yes, #194 fixed this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
test an issue relating to tests
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants