I’m finding that error messages on Pact consumer failure (when using the arrayContaining matcher) are not very helpful at pinpointing what part of the data is incorrect.
The only error message is that the entry we're looking for wasn't found.
For example:
Variant at index 0 ({"attributes":{"createdAt":"2025-11-19T08:37:43.937Z","someProperty":{"image":{"alt":"Some alt text","url":"https://example.com?some-image.jpg"},"otherUrl":"https://example.com?some-image.jpg"},"payload":{"payload":{"someProperty":{"alt":"Some alt text","otherUrl":"https://example.com?some-image.jpg","url":"https://example.com?some-image.jpg"},"ctaTitleOverride":"some text","titleOverride":"some text","welcomeMessage":"Welcome!"},"type":"some-type"},"publishedAt":"2025-11-19T08:37:43.937Z","levels":["high"],"type":"some-type"},"id":"some-uuid","type":"another-type"}) was not found in the actual list
When I'm looking at that message, I have no idea what part of it is incorrect.
In my context, this is a test that used to work, but is now failing – which indicates that it's likely something small that has changed on the provider (it turned out to be different casing for one of the data keys).
Testing libraries like Jest & Vitest have a useful way of showing the diffs of expected versus actual, so it would be really useful to have something like that.
I realise this is likely quite challenging with the arrayContaining matcher, but it would make a massive difference in tracking down the error.
I’m finding that error messages on Pact consumer failure (when using the
arrayContainingmatcher) are not very helpful at pinpointing what part of the data is incorrect.The only error message is that the entry we're looking for wasn't found.
For example:
When I'm looking at that message, I have no idea what part of it is incorrect.
In my context, this is a test that used to work, but is now failing – which indicates that it's likely something small that has changed on the provider (it turned out to be different casing for one of the data keys).
Testing libraries like Jest & Vitest have a useful way of showing the diffs of expected versus actual, so it would be really useful to have something like that.
I realise this is likely quite challenging with the
arrayContainingmatcher, but it would make a massive difference in tracking down the error.