(Aspects): Aspects do not work during unit tests #24220
Labels
@aws-cdk/aws-s3
Related to Amazon S3
bug
This issue is a bug.
needs-triage
This issue or PR still needs to be triaged.
package/tools
Related to AWS CDK Tools or CLI
Describe the bug
Aspects work as expected when attempting to synth or deploy from an entrypoint file like
src/main.ts
. However, it appears that something is interrupting this when the same code is used in a unit test.Expected Behavior
Aspect annotations should appear on stacks and templates when used in a unit test.
Current Behavior
Aspects have no effect when used in a unit test.
Reproduction Steps
Add this code to your
src/main.ts
file and runcdk synth
. It will log a number of issues to the console.However if you add it during a unit test, eg
src/test/Bucket.test.ts
, it appears that Aspects no longer function.This will output a JSON representation of the stack and no annotations have been added. Creating a basic S3 bucket like this should light up the AwsSolutionsChecks with many errors (missing replication, encryption, logging, etc). However, nothing occurs.
Possible Solution
No response
Additional Information/Context
Related issues:
CDK CLI Version
2.65.0
Framework Version
No response
Node.js Version
v16.14.0
OS
na
Language
Typescript
Language Version
TypeScript (4.8.4)
Other information
No response
The text was updated successfully, but these errors were encountered: