You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The “NAME” field informed in the error message is not incorrect, what is incorrect is the “AGE”.
test('check if value array matches the given subset', function () {
expect(['name' => 'lobo', 'age' => 10])->toMatchArray(['name' => 'lobo', 'age' => 0]);
});
Failed asserting that an array has a key 'name' with the value 'lobo'.
Failed asserting that 10 matches expected 0.
Expected :0
Actual :10
How to Reproduce
test('check if value array matches the given subset', function () {
expect(['name' => 'lobo', 'age' => 10])->toMatchArray(['name' => 'lobo', 'age' => 0]);
});
Sample Repository
No response
Pest Version
2.16.1
PHP Version
8.1
Operation System
Linux
Notes
No response
The text was updated successfully, but these errors were encountered:
HENRIQUELOBO
changed the title
[Bug]: toMatchArray - Field informed in the error message is the correct.
[Bug]: toMatchArray - Field informed in the error message is the incorrect.
Aug 31, 2023
I was able to reproduce the behavior reported for you, but I don't think this is a bug or something related to that, I mean something that requires special attention. I will tag this as an enhancement to future Pest releases. Feel free to send us a PR with the enhancement in this part.
Why is reporting the wrong field not an error? Just spend 2 hours trying to figure out on a large array what is not matching.
Getting a headache from the logic when $message from Assert::assertArrayHasKey($key, $valueAsArray, $message); is empty, it is considered as an error and $message is updated. It looks very hacky and wrong.
What Happened
The “NAME” field informed in the error message is not incorrect, what is incorrect is the “AGE”.
test('check if value array matches the given subset', function () {
expect(['name' => 'lobo', 'age' => 10])->toMatchArray(['name' => 'lobo', 'age' => 0]);
});
Failed asserting that an array has a key 'name' with the value 'lobo'.
Failed asserting that 10 matches expected 0.
Expected :0
Actual :10
How to Reproduce
test('check if value array matches the given subset', function () {
expect(['name' => 'lobo', 'age' => 10])->toMatchArray(['name' => 'lobo', 'age' => 0]);
});
Sample Repository
No response
Pest Version
2.16.1
PHP Version
8.1
Operation System
Linux
Notes
No response
The text was updated successfully, but these errors were encountered: