# MatchResult

The result of `Match.test()`.

- Source: [`assertions/lib/matcher.ts`](https://github.com/aws/aws-cdk/blob/v2.275.0/packages/aws-cdk-lib/assertions/lib/matcher.ts#L77)
- Type last changed: v2.58.0 · 29 Dec 2022

## Example

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

declare const target: any;
const matchResult = new assertions.MatchResult(target);
```

## Initializer

```ts
new MatchResult(target: any)
```

## Properties

- `failCost`: number — The cost of the failures so far.

- `failCount`: number — The number of failures.

- `isSuccess`: boolean — Whether the match is a success.

- `target`: any — The target for which this result was generated.

## Methods

- `compose(id: string, inner: MatchResult): MatchResult // chainable` — Compose the results of a previous match as a subtree.

  **Parameters**

  - `id` — the id of the parent tree.

- `finished(): MatchResult // chainable` — Prepare the result to be analyzed.

  This API *must* be called prior to analyzing these results.

- `hasFailed(): boolean` — Does the result contain any failures.

  If not, the result is a success

- `push(matcher: Matcher, path: string[], message: string): MatchResult // chainable` — use recordFailure()

- `recordCapture(options: MatchCapture): void` — Record a capture against in this match result.

- `recordFailure(failure: MatchFailure): MatchResult // chainable` — Record a new failure into this result at a specific path.

- `renderMismatch(): string` — Do a deep render of the match result, showing the structure mismatches in context.

- `toHumanStrings(): string[]` — Render the failed match in a presentable way.

  Prefer using `renderMismatch` over this method. It is left for backwards
  compatibility for test suites that expect it, but `renderMismatch()` will
  produce better output.
