Open alekdavis opened 2 weeks ago
The following script could be helpful for testing:
### A
# @name a
POST https://httpbin.org/anything
?? status == 201
### B
# @name b
# @ref a
{{
exports.$cancel = (aResponse?.statusCode !== 201);
}}
PATCH https://httpbin.org/anything
?? status == 200
### C
# @name c
# @ref b
{{
exports.$cancel = (bResponse?.statusCode !== 200);
}}
GET https://httpbin.org/anything?b={{bResponse?.statusCode}}
?? status == 200
### D
# @name d
# @ref b
{{
exports.$cancel = (bResponse?.statusCode !== 200);
}}
GET https://httpbin.org/json?b={{bResponse?.statusCode}}
?? status == 200
It should produce test results:
---------------------
=== A ===
POST https://httpbin.org/anything
=> 200 (545 ms, 590 B)
✖ status == 201 (AssertionError [ERR_ASSERTION]: status (200) == 201)
---------------------
=== B ===
PATCH https://httpbin.org/anything
○ Test skipped
---------------------
=== C ===
GET https://httpbin.org/anything?b={{bResponse?.statusCode}}
○ Test skipped
---------------------
=== D ===
GET https://httpbin.org/json?b={{bResponse?.statusCode}}
○ Test skipped
The following code illustrates nested dependency. Test A completes request, but fails assertion. Test B depends on some condition of test A and test C depends on some condition of test B:
In , v6.16.2, the result is what you'd expect: both tests B and C get skipped:
In In , v6.16.3 and 6.16.4, test B gets skipped, but the pre-request script of test C does not get processed due to the
ReferenceError: bResponse is not defined
error. So, the code to set the$cancel
variable does not complete and test C is executed:However, test C shows everywhere as successfully executed:
I think the test dependency logic in v6.16.2 was mostly correct. The only issue I seem to see with v6.16.2 is that it would try to invoke a failed test multiple times during a test run (for every
@ref
). But v6.16.3 and v6.16.4 do not work with my logic at all unless I'm doing something wrong.