Hi, I'm trying to use eachLike with a minimum of 2...
# pact-js
l
Hi, I'm trying to use eachLike with a minimum of 2, according to this documentation:
Copy code
eachLike(propertyDocumentWithoutTransactions, { min: 2 })
However, I'm having the following warning when running the test:
Pact Binary Error: WARN: Only the first item will be used to match the items in the array at $['body']['addresses']
Can anyone help explain what this means?
m
Can you please show what value you've passed in as the first Arg?
And also the context in which it's used? It may not actually be an issue
Is that error on the consumer or provider side?
t
This happens when you try to specify more than one array item I think. The first argument should describe a single entry of the array that will be used to match all entries
Oh wait, no. I think this is a bug in the ruby core: https://github.com/pact-foundation/pact-js/blob/master/src/dsl/matchers.ts#L68
or in the pact-js matchers
o
I was working with Laura on this so providing the additional details: Value of the first arg that’s being passed in:
Copy code
{
    address: {
        uprn: integer()
    },
    transactions: {
        sales: {
            history: eachLike({
                price: integer(),
                date: iso8601Date()
            })
        }
    }
}
The error is when running the consumer contract tests; here’s the context:
Copy code
await provider.addInteraction({
    // ...
    willRespondWith: {
	    // ...
        body: {
            addresses: eachLike(propertyDocument, { min: 2 }),
        }
    }
});
The tests still run so it’s probably not a problem, but the error threw us off a bit and it’s not clear if we need to do something about it?
t
I don't think you need to do something about it, but I do think it's a bug. Might be worth opening an issue about it
After looking at the additional details, I'm certain this isn't anything you've done.
Another improvement that could be made is to stop pact from saying there was an error when the only lines to stderr start with WARN
(It should still print the warning)
m
I don’t think you need to do something about it, but I do think it’s a bug. Might be worth opening an issue about it
I recall this is a recurring issue that Beth has just never been able to fully whack-a-mole to completion.
So I’d just plod on, and if it causes issues on the provider side we can look into it. It looks good to my eyes also
t
I think this might even happen in one of the examples :/
😆 1
o
Thanks both, it seems to behave fine on the provider side so all is well
👍 1