Assert package doesn't synthesize the stack

Open
#349 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
45/100
Issue type
Documentation
Clarity
Mostly clear
Activity status
Stale
Tech stack
aws, typescript

Research direction

Start with the Fine-grained Assertions section in doc_source/testing.md and reproduce the example using a custom Stack, moving resource creation inside the stack as described. Compare the matcher input with the SynthUtils.toCloudFormation(MyStack) example; done means the documentation clearly reflects the real-world test setup and the assertion reports the expected resources.

Written by the indexing model from the issue text.

Description

If you follow the documentation for Fine-grained Assertions - the test will pass.

It's not a real-world scenario though - you don't create a resource in a test, you create the resource in the stack definition.

If you modify the test and move new dlq.DeadLetterQueue(...) inside of the new Stack() call (assuming new Stack() is a custom stack like export class MyStack extends Stack { ... }, the test will fail and indicate that there are 0 resources.


You can fix this error by adding a line; const stackTemplate = SynthUtils.toCloudFormation(new MyStack()) and passing the stackTemplate variable to the expect(...) call instead of the stack variable.

I'm not sure if this is a bug with the jest matcher though, or whether this fix is the right approach and the documentation just isn't quite matching up to a real-world scenario?

Dominant language
Perl
Stars
360
Forks
230
Avg merge
3d 23h
Merged PRs (30d)
1

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from awsdocs/aws-cdk-guide

All issues in awsdocs/aws-cdk-guide

Similar issues

More Perl issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.