add custom message to failed expectations

This commit is contained in:
Fabio Ivona
2022-09-19 09:03:27 +02:00
parent c5cb1fc325
commit 8a3caa5e7f
55 changed files with 424 additions and 143 deletions

View File

@ -20,9 +20,13 @@ it('passes with *not*', function () {
});
it('properly fails with *not*', function () {
expect('pest')->not->toHaveLength(4);
expect('pest')->not->toHaveLength(4, 'oh no!');
})->throws(ExpectationFailedException::class, 'oh no!');
it('fails', function () {
expect([1, 1.5, true, null])->toHaveLength(1);
})->throws(ExpectationFailedException::class);
it('fails', function ($value) {
expect($value)->toHaveLength(1);
})->with([1, 1.5, true, null])->throws(BadMethodCallException::class);
it('fails with message', function () {
expect([1, 1.5, true, null])->toHaveLength(1, 'oh no!');
})->throws(ExpectationFailedException::class, 'oh no!');