[@aws-cdk/core] Issue Creating Stack in Unit Tests after 1.58.0 Update
See original GitHub issueWith the 1.58.0 update all of my tests fail with the following error:
unexpected: all stacks must be part of a Stage or an App
All of these tests pass under 1.57.0, and reading the release notes for 1.58.0 it seems like the code below should still work.
Reproduction Steps
const stack = new Stack();
new Bucket(stack, 'bucket');
expectCDK(stack).to(haveResource('AWS::S3::Bucket'));
What actually happened?
The test fails with the following error:
unexpected: all stacks must be part of a Stage or an App
I thought what the heck, make an app and pass that into the stack as its scope, but even with that I still got the same error.
Environment
- CLI Version: 1.58.0
- Framework Version:1.58.0
- Node.js Version: 12.18.2
- OS : macOS 10.15.6
- Language (Version): Typescript
This is 🐛 Bug Report
Issue Analytics
- State:
- Created 3 years ago
- Comments:9 (2 by maintainers)
Top Results From Across the Web
Troubleshooting common AWS CDK issues
This topic describes how to troubleshoot the following issues with the AWS CDK. After updating the AWS CDK, the AWS CDK Toolkit (CLI)...
Read more >Testing constructs - AWS Cloud Development Kit (AWS CDK) v2
To illustrate how to write these tests, we'll create a stack that contains an AWS Step Functions state machine and an AWS Lambda...
Read more >Troubleshooting common AWS CDK issues
This topic describes how to troubleshoot the following issues with the AWS CDK. After updating the AWS CDK, code that used to work...
Read more >Testing constructs - AWS Cloud Development Kit (AWS CDK) v1
We'll modify the app's main entry point to not actually instantiate our stack, since we don't want to accidentally deploy it. Our tests...
Read more >Testing CDK Applications in Any Language - Amazon AWS
Because the AWS CDK enables you to define your infrastructure in regular programming languages, you can also write automated unit tests for ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I suspect this might be a result of multiple versions of CDK modules in your
node_modules
. Can you please verify yourpackage.json
uses the same version for all CDK modules, nuke yournode_modules
and re-runnpm install
(oryarn install
)?Having the same problem even with 1.70.0 [edit] Seem to have worked by changing
"@aws-cdk/assert": "1.70.0"
to"@aws-cdk/assert": "^1.70.0"