Skip to content

(assertions): Add ability to read Annotations #18347

@dontirun

Description

@dontirun

Description

Add the ability to read and validate against Annotations with the the assertions

Use Case

The @aws-cdk/assert module has the ability to read messages of stack using SynthUtils. This is helpful when trying to validate that there are no errors/warnings in the stack, especially when using Aspects to apply annotations

test('Example', () => {
  const stack = new Stack();
  // Aspects.of(stack).add(new MyAspect());
  Annotations.of(stack).addError('MyError')
  const messages = SynthUtils.synthesize(stack).messages;
  expect(messages).not.toContainEqual(
    expect.objectContaining({
      entry: expect.objectContaining({
        data: expect.stringContaining(
          'MyError',
        ),
      }),
    }),
  );
});

Proposed Solution

It would be nice to have something like
assertions.Annotations.of(stack)
assertions.Annotations.of(app)

Other information

No response

Acknowledge

  • I may be able to implement this feature request
  • This feature might incur a breaking change

Metadata

Metadata

Assignees

Labels

@aws-cdk/assertionsRelated to the @aws-cdk/assertv2 packageeffort/mediumMedium work item – several days of effortfeature-requestA feature should be added or improved.p1

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions