# Annotations

Suite of assertions that can be run on a CDK Stack.

Focused on asserting annotations.

- Source: [`assertions/lib/annotations.ts`](https://github.com/aws/aws-cdk/blob/v2.275.0/packages/aws-cdk-lib/assertions/lib/annotations.ts#L12)
- Type last changed: v2.17.0 · 17 Mar 2022

## Example

```ts
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import * as cdk from 'aws-cdk-lib';
import { assertions } from 'aws-cdk-lib';

declare const stack: cdk.Stack;
const annotations = assertions.Annotations.fromStack(stack);
```

## Methods

- `findError(constructPath: string, message: any): SynthesisMessage[]` — Get the set of matching errors of a given construct path and message.

  **Parameters**

  - `constructPath` — the construct path to the error, provide `'*'` to match all errors in the template.
  - `message` — the error message as should be expected.

- `findInfo(constructPath: string, message: any): SynthesisMessage[]` — Get the set of matching infos of a given construct path and message.

  **Parameters**

  - `constructPath` — the construct path to the info, provide `'*'` to match all infos in the template.
  - `message` — the info message as should be expected.

- `findWarning(constructPath: string, message: any): SynthesisMessage[]` — Get the set of matching warning of a given construct path and message.

  **Parameters**

  - `constructPath` — the construct path to the warning, provide `'*'` to match all warnings in the template.
  - `message` — the warning message as should be expected.

- `fromStack(stack: Stack): Annotations // chainable` (static) — Base your assertions on the messages returned by a synthesized CDK `Stack`.

  **Parameters**

  - `stack` — the CDK Stack to run assertions on.

- `hasError(constructPath: string, message: any): void` — Assert that an error with the given message exists in the synthesized CDK `Stack`.

  **Parameters**

  - `constructPath` — the construct path to the error, provide `'*'` to match all errors in the template.
  - `message` — the error message as should be expected.

- `hasInfo(constructPath: string, message: any): void` — Assert that an info with the given message exists in the synthesized CDK `Stack`.

  **Parameters**

  - `constructPath` — the construct path to the info, provide `'*'` to match all info in the template.
  - `message` — the info message as should be expected.

- `hasNoError(constructPath: string, message: any): void` — Assert that an error with the given message does not exist in the synthesized CDK `Stack`.

  **Parameters**

  - `constructPath` — the construct path to the error, provide `'*'` to match all errors in the template.
  - `message` — the error message as should be expected.

- `hasNoInfo(constructPath: string, message: any): void` — Assert that an info with the given message does not exist in the synthesized CDK `Stack`.

  **Parameters**

  - `constructPath` — the construct path to the info, provide `'*'` to match all info in the template.
  - `message` — the info message as should be expected.

- `hasNoWarning(constructPath: string, message: any): void` — Assert that a warning with the given message does not exist in the synthesized CDK `Stack`.

  **Parameters**

  - `constructPath` — the construct path to the warning, provide `'*'` to match all warnings in the template.
  - `message` — the warning message as should be expected.

- `hasWarning(constructPath: string, message: any): void` — Assert that a warning with the given message exists in the synthesized CDK `Stack`.

  **Parameters**

  - `constructPath` — the construct path to the warning, provide `'*'` to match all warnings in the template.
  - `message` — the warning message as should be expected.
