aws-cdk-lib.assertions.MatchResult

class MatchResult

LanguageType name
.NETAmazon.CDK.Assertions.MatchResult
Gogithub.com/aws/aws-cdk-go/awscdk/v2/assertions#MatchResult
Javasoftware.amazon.awscdk.assertions.MatchResult
Pythonaws_cdk.assertions.MatchResult
TypeScript (source)aws-cdk-lib » assertions » MatchResult

The result of Match.test().

Example

// 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

new MatchResult(target: any)

Parameters

  • target any

Properties

NameTypeDescription
failCostnumberThe cost of the failures so far.
failCountnumberThe number of failures.
isSuccessbooleanWhether the match is a success.
targetanyThe target for which this result was generated.

failCost

Type: number

The cost of the failures so far.


failCount

Type: number

The number of failures.


isSuccess

Type: boolean

Whether the match is a success.


target

Type: any

The target for which this result was generated.

Methods

NameDescription
compose(id, inner)Compose the results of a previous match as a subtree.
finished()Prepare the result to be analyzed.
hasFailed()Does the result contain any failures.
push(matcher, path, message)⚠️DEPRECATED.
recordCapture(options)Record a capture against in this match result.
recordFailure(failure)Record a new failure into this result at a specific path.
renderMismatch()Do a deep render of the match result, showing the structure mismatches in context.
toHumanStrings()Render the failed match in a presentable way.

compose(id, inner)

public compose(id: string, inner: MatchResult): MatchResult

Parameters

  • id string — the id of the parent tree.
  • inner MatchResult

Returns

  • MatchResult

Compose the results of a previous match as a subtree.


finished()

public finished(): MatchResult

Returns

  • MatchResult

Prepare the result to be analyzed.

This API must be called prior to analyzing these results.


hasFailed()

public hasFailed(): boolean

Returns

  • boolean

Does the result contain any failures.

If not, the result is a success


push(matcher, path, message)⚠️

public push(matcher: Matcher, path: string[], message: string): MatchResult

⚠️ Deprecated: use recordFailure()

Parameters

  • matcher Matcher
  • path string[]
  • message string

Returns

  • MatchResult

DEPRECATED.


recordCapture(options)

public recordCapture(options: MatchCapture): void

Parameters

  • options MatchCapture

Record a capture against in this match result.


recordFailure(failure)

public recordFailure(failure: MatchFailure): MatchResult

Parameters

  • failure MatchFailure

Returns

  • MatchResult

Record a new failure into this result at a specific path.


renderMismatch()

public renderMismatch(): string

Returns

  • string

Do a deep render of the match result, showing the structure mismatches in context.


toHumanStrings()

public toHumanStrings(): string[]

Returns

  • 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.