> **Experimental**
>
> `@aws-cdk/integ-tests-alpha` is an [**experimental**](/stability) (alpha) package: its API may change in any release, without a major version bump.
# ExpectedResult

Represents the "expected" results to compare.

Obtainable from: ExpectedResult.arrayWith, ExpectedResult.exact, ExpectedResult.objectLike, ExpectedResult.stringLikeRegexp

- Stability: [Experimental](/cdk/api/stability.html)
- Source: [`lib/assertions/common.ts`](https://github.com/aws/aws-cdk/blob/v2.277.0/packages/@aws-cdk/integ-tests-alpha/lib/assertions/common.ts#L35)

## Example

TypeScript:

```ts
declare const app: App;
declare const stack: Stack;
declare const sm: IStateMachine;

const testCase = new IntegTest(app, 'IntegTest', {
  testCases: [stack],
});

// Start an execution
const start = testCase.assertions.awsApiCall('StepFunctions', 'startExecution', {
  stateMachineArn: sm.stateMachineArn,
});

// describe the results of the execution
const describe = testCase.assertions.awsApiCall('StepFunctions', 'describeExecution', {
  executionArn: start.getAttString('executionArn'),
});

// assert the results
describe.expect(ExpectedResult.objectLike({
  status: 'SUCCEEDED',
}));
```

Python:

```python
# app: App
# stack: Stack
# sm: IStateMachine

test_case = IntegTest(app, "IntegTest",
    test_cases=[stack]
)

# Start an execution
start = test_case.assertions.aws_api_call("StepFunctions", "startExecution", {
    "state_machine_arn": sm.state_machine_arn
})

# describe the results of the execution
describe = test_case.assertions.aws_api_call("StepFunctions", "describeExecution", {
    "execution_arn": start.get_att_string("executionArn")
})

# assert the results
describe.expect(ExpectedResult.object_like({
    "status": "SUCCEEDED"
}))
```

Java:

```java
App app;
Stack stack;
IStateMachine sm;

IntegTest testCase = IntegTest.Builder.create(app, "IntegTest")
        .testCases(List.of(stack))
        .build();

// Start an execution
IApiCall start = testCase.assertions.awsApiCall("StepFunctions", "startExecution", Map.of(
        "stateMachineArn", sm.getStateMachineArn()));

// describe the results of the execution
IApiCall describe = testCase.assertions.awsApiCall("StepFunctions", "describeExecution", Map.of(
        "executionArn", start.getAttString("executionArn")));

// assert the results
describe.expect(ExpectedResult.objectLike(Map.of(
        "status", "SUCCEEDED")));
```

C# / .NET:

```csharp
// Install: dotnet add package Amazon.CDK.IntegTests.Alpha
App app;
Stack stack;
IStateMachine sm;

var testCase = new IntegTest(app, "IntegTest", new IntegTestProps {
    TestCases = new [] { stack }
});

// Start an execution
var start = testCase.Assertions.AwsApiCall("StepFunctions", "startExecution", new Dictionary<string, string> {
    { "stateMachineArn", sm.StateMachineArn }
});

// describe the results of the execution
var describe = testCase.Assertions.AwsApiCall("StepFunctions", "describeExecution", new Dictionary<string, string> {
    { "executionArn", start.GetAttString("executionArn") }
});

// assert the results
describe.Expect(ExpectedResult.ObjectLike(new Dictionary<string, object> {
    { "status", "SUCCEEDED" }
}));
```

Golang:

```go
// Install: go get github.com/aws/aws-cdk-go/awscdkintegtestsalpha/v2
var app App
var stack Stack
var sm IStateMachine

testCase := awscdkintegtestsalpha.NewIntegTest(app, jsii.String("IntegTest"), &IntegTestProps{
	TestCases: []Stack{
		stack,
	},
})

// Start an execution
start := testCase.Assertions.AwsApiCall(jsii.String("StepFunctions"), jsii.String("startExecution"), map[string]*string{
	"stateMachineArn": sm.stateMachineArn,
})

// describe the results of the execution
describe := testCase.Assertions.AwsApiCall(jsii.String("StepFunctions"), jsii.String("describeExecution"), map[string]*string{
	"executionArn": start.getAttString(jsii.String("executionArn")),
})

// assert the results
describe.Expect(awscdkintegtestsalpha.ExpectedResult_ObjectLike(map[string]interface{}{
	"status": jsii.String("SUCCEEDED"),
}))
```

## Initializer

TypeScript:

```ts
new ExpectedResult()
```

Python:

```python
ExpectedResult()
```

Java:

```java
new ExpectedResult()
```

C# / .NET:

```csharp
new ExpectedResult()
```

Golang:

```go
NewExpectedResult()
```

## Properties

- `result`: string — The expected results encoded as a string.

## Methods

- `arrayWith(expected: any[]): ExpectedResult // chainable` (static) — The actual results must be a list and must contain an item with the expected results.

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

- `exact(expected: any): ExpectedResult // chainable` (static) — The actual results must match exactly.

  Missing data
  will result in a failure

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

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

- `objectLike(expected: { [key: string]: any }): ExpectedResult // chainable` (static) — The expected results must be a subset of the actual results.

  ```ts
  // actual results
  const actual = {
    stringParam: 'hello',
    numberParam: 3,
    booleanParam: true,
    objectParam: { prop1: 'value', prop2: 'value' },
  };
  // pass
  ExpectedResult.objectLike({
    stringParam: 'hello',
    objectParam: { prop1: 'value' },
  });
  ```

- `stringLikeRegexp(expected: string): ExpectedResult // chainable` (static) — Actual results is a string that matches the Expected result regex.

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

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