-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Description
Describe the bug
I am trying to build a test that codes roughly does:
const getUploadUrl = integ.assertions
.httpApiCall(`${testStack.apiUrl}outbox/${id}`, {
method: 'PUT',
})
.expect(
test.ExpectedResult.objectLike({
status: 201,
headers: {
'content-type': ['application/json'],
},
body: {
id: emailId,
},
}),
)
.waitForAssertions();
const uploadUrl = getUploadUrl.getAttString('body.uploadUrl');as you can see I am trying to get my hands on uploadUrl from response body.
the assertion expressed in expect works fine (although there's no checkup for uploadUrl but just because I am not sure if I can nest expectation). Still, I am confident that uploadUrl is present in response body based on logs.
Is httpApiCall broken? I have located a lot of examples where getAtString is used in cdk own test suites. Difference is that it is rather used with awsSdkCall or lambdaInvokeFunction rather then httpApiCall.
Use case
Use case is to be able to integ test parts of bigger component.
Without a need to deploy the whole component.
Expected Behavior
I can obtain part of response via HttApiCall
Current Behavior
Test fails with Vendor response doesn't contain apiCallResponse.body.uploadUrl
Reproduction Steps
import 'source-map-support/register';
import * as test from '@aws-cdk/integ-tests-alpha';
import * as cdk from 'aws-cdk-lib';
const app = new cdk.App({
analyticsReporting: false,
stackTraces: true,
});
const testStack = new cdk.Stack(app, 'repro-api-stack');
const integ = new test.IntegTest(app, 'repro-api-test', {
testCases: [testStack],
});
const apiCall = integ.assertions.httpApiCall(
'https://cat-fact.herokuapp.com/facts',
);
const value = apiCall.getAttString('body.0.user');
integ.assertions
.httpApiCall(`https://cat-fact.herokuapp.com/users/${value}`)
.expect(
test.ExpectedResult.objectLike({
status: 404,
}),
);Possible Solution
N/A
Additional Information/Context
N/A
CDK CLI Version
2.142.1
Framework Version
No response
Node.js Version
20.8
OS
MacOS sierra
Language
TypeScript
Language Version
5.4
Other information
No response