integ-tests: assertion chaining do not fail as expected #32604
Labels
@aws-cdk/assertions
Related to the @aws-cdk/assertv2 package
bug
This issue is a bug.
effort/medium
Medium work item – several days of effort
p2
Describe the bug
The various implementations of
IApiCall
(awsApiCall
,invokeFunction
andhttpApiCall
) are used to run assertions on integration test after their deployment. These API or HTTP calls can be reused to run multiple assertions over a single result, either by chaining them or storing the result in a variable and reusing it. Unfortunately, it seems that only the last assertion evaluated for anIApiCall
instance seem to determine whether the assertion will pass or fail the test.Regression Issue
Last Known Working CDK Version
No response
Expected Behavior
Each assertions made to a
IApiCall
construct should be evaluated, and the tests should only pass if every one is validCurrent Behavior
When running multiple assertions on the same
IApiCall
, only the last assertion determines whether it fails or passes.Reproduction Steps
Given the following integration test, based off of integ.assertions.ts:
The following assertions fail, as expected:
But the following assertions pass, as their last
expect
/assertAtPath
calls pass:We can see the same issue occurring with
httpApiCall
andinvokeFunction
, as these assertions pass erroneously:Possible Solution
The brute and safe solution would be to render these assertion functions effective singletons, by throwing an error if the instance of the
IApiCall
construct is used more than once. This would allow us to at least root out all potential silently failing tests.Additional Information/Context
We have multiple instances of multiple assertions being made to a single
IApiCall
, such as:aws-cdk/packages/@aws-cdk-testing/framework-integ/test/aws-iam/test/integ.imported-role.ts
Lines 65 to 80 in 034679a
This might be a regression, but I cannot confirm that this was ever working properly
CDK CLI Version
v2.173.2 (034679a)
Framework Version
No response
Node.js Version
v20.11.1
OS
macOS
Language
TypeScript
Language Version
TypeScript ~5.5.2 (internal version)
Other information
Originally reported by @brandondahler in #32575 (comment)
The text was updated successfully, but these errors were encountered: