bballoon_guy
bballoon_guy

Reputation: 49

Retry until condition failing

My retry until condition fails. This is my code

Feature: some feature...
Scenario: some scenario...
    * configure retry = {count: 5, interval: 5000}

    # Given endpoint
    Given path 'orders'
    And retry until response.orders == [] && responseStatus == 200
    When method GET
    Then status 200

I get this error while executing:

retry condition not satisfied: response.orders == [] && responseStatus == 200

I've also tried it with response.orders == '#[0]' which also gives the same error.

This is my API response:

{
   "id": null,
   "orders": []
}

I also tried response.orders.length == 0 but that gives me this error:

Cannot read property "length" from undefined

What is going wrong?

Upvotes: 1

Views: 34

Answers (1)

bballoon_guy
bballoon_guy

Reputation: 49

After referring to this answer from the comment, I figured that the reason my condition was failing was because my response was not yet ready. Replacing the condition to this:

And retry until response.orders && response.orders.length == 0

helped to wait for the response to be ready and then check the length of the response.

Upvotes: 0

Related Questions