question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[@aws-cdk/core] Issue Creating Stack in Unit Tests after 1.58.0 Update

See original GitHub issue

With 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:closed
  • Created 3 years ago
  • Comments:9 (2 by maintainers)

github_iconTop GitHub Comments

9reactions
eladbcommented, Aug 16, 2020

I suspect this might be a result of multiple versions of CDK modules in your node_modules. Can you please verify your package.json uses the same version for all CDK modules, nuke your node_modules and re-run npm install (or yarn install)?

1reaction
Sergio-PBcommented, Oct 29, 2020

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"

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found