Skip to content

Pact error messages for arrayContaining matcher are hard to decipher #1614

Description

@mcalthrop

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementIndicates new feature requeststriageThis issue is yet to be triaged by a maintainerupstreamIndicates that an issue relates to an upstream problem (such as in pact-reference)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions