pact-foundation/pact-support

Validate the results regarding the order

LindomarReitz opened this issue · 1 comments

Hi,

Depending on the response from an API, the order of the results can be different.

The pact file expects:

        "body": {
           "entries": [
            {
                "name": "item1" 
            },
            {
                "name": "item2" 
            } 
           ]  
        }

The API response returns:

        "body": {
           "entries": [
            {
                "name": "item2"
            },
            {
                "name": "item1"
            }
           ]  
        }

This cause the error: * Expected "item1" but got "item2" at $.entries[0].name. Is it possible to validate the pact regarding the order?

I'm not sure if this is a problem from verification, or if have some performance concerns to validate the content in this way.

We don't currently have a matcher that says "these items in any order". You can only say "all items that look like this". I think it's already raised in the pact-specification, but if it isn't, can you raise it there, and we'll look at adding it to a future version.