@aws-cdk_integ-tests-alpha.ExpectedResult

class ExpectedResult ๐Ÿ”น

LanguageType name
.NETAmazon.CDK.IntegTests.Alpha.ExpectedResult
Gogithub.com/aws/aws-cdk-go/awscdkintegtestsalpha/v2#ExpectedResult
Javasoftware.amazon.awscdk.integtests.alpha.ExpectedResult
Pythonaws_cdk.integ_tests_alpha.ExpectedResult
TypeScript (source)@aws-cdk/integ-tests-alpha ยป ExpectedResult

Represents the "expected" results to compare.

Example

declare const app: App;
declare const integ: IntegTest;
integ.assertions.awsApiCall('SQS', 'sendMessage', {
  QueueUrl: 'url',
  MessageBody: 'hello',
});
const message = integ.assertions.awsApiCall('SQS', 'receiveMessage', {
  QueueUrl: 'url',
});
message.expect(ExpectedResult.objectLike({
  Messages: [{ Body: 'hello' }],
}));

Initializer

new ExpectedResult()

Properties

NameTypeDescription
result๐Ÿ”นstringThe expected results encoded as a string.

result๐Ÿ”น

Type: string

The expected results encoded as a string.

Methods

NameDescription
static arrayWith(expected)๐Ÿ”นThe actual results must be a list and must contain an item with the expected results.
static exact(expected)๐Ÿ”นThe actual results must match exactly.
static objectLike(expected)๐Ÿ”นThe expected results must be a subset of the actual results.
static stringLikeRegexp(expected)๐Ÿ”นActual results is a string that matches the Expected result regex.

static arrayWith(expected)๐Ÿ”น

public static arrayWith(expected: any[]): ExpectedResult

Parameters

  • expected any[]

Returns

  • ExpectedResult

The actual results must be a list and must contain an item with the expected results. Example

// actual results
const actual = [
  {
    stringParam: 'hello',
  },
  {
    stringParam: 'world',
  },
];
// pass
ExpectedResult.arrayWith([
  {
    stringParam: 'hello',
  },
]);

static exact(expected)๐Ÿ”น

public static exact(expected: any): ExpectedResult

Parameters

  • expected any

Returns

  • ExpectedResult

The actual results must match exactly.

Missing data will result in a failure Example

// actual results
const actual = {
  stringParam: 'hello',
  numberParam: 3,
  booleanParam: true,
};
// pass
ExpectedResult.exact({
  stringParam: 'hello',
  numberParam: 3,
  booleanParam: true,
})

// fail
ExpectedResult.exact({
  stringParam: 'hello',
});

static objectLike(expected)๐Ÿ”น

public static objectLike(expected: { [string]: any }): ExpectedResult

Parameters

  • expected { [string]: any }

Returns

  • ExpectedResult

The expected results must be a subset of the actual results. Example

// actual results
const actual = {
  stringParam: 'hello',
  numberParam: 3,
  booleanParam: true,
};
// pass
ExpectedResult.objectLike({
  stringParam: 'hello',
});

static stringLikeRegexp(expected)๐Ÿ”น

public static stringLikeRegexp(expected: string): ExpectedResult

Parameters

  • expected string

Returns

  • ExpectedResult

Actual results is a string that matches the Expected result regex. Example

// actual results
const actual = 'some string value';

// pass
ExpectedResult.stringLikeRegexp('value');