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

Created on 13 Aug 2020  路  9Comments  路  Source: aws/aws-cdk

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: Bug Report

@aws-cdcore bug needs-triage

Most helpful comment

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)?

All 9 comments

I am having the same issue with 1.58.0 update.

Having the same issue as well with 1.58.0

+1

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)?

Please comment if the proposed solution did not work.

Clearing out the node_modules folder wasn't enough for me, I had to nuke the package-lock.json too. Seems to be every CDK upgrade I'm having to do this. It's getting a bit boring now! 馃槥

I am having the same issue with 1.68.0

I was having the same issue with 1.69.0, I tried to clean node_modules folder etc. but it didn't help. Now 1.70.0 upgrade fixed the issue.

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"

Was this page helpful?
0 / 5 - 0 ratings

Related issues

nzspambot picture nzspambot  路  3Comments

schof picture schof  路  3Comments

kawamoto picture kawamoto  路  3Comments

slipdexic picture slipdexic  路  3Comments

artyom-melnikov picture artyom-melnikov  路  3Comments