pestphp / pest

Pest is an elegant PHP testing Framework with a focus on simplicity, meticulously designed to bring back the joy of testing in PHP.
https://pestphp.com
MIT License
9.48k stars 343 forks source link

Handle http response #1112

Open skrskr opened 6 months ago

skrskr commented 6 months ago

I'm tring to test api using pest and i'm looking for alternative functions for assertOk(), assertJsonStructure

  $response->assertOk()->assertJsonStructure([
      'data' => [
          'event',
      ],
      'message',
  ]);

I used expect()->extend()

expect()->extend('toBeOk', function () {
    return $this->toBe(Response::HTTP_OK);
});

If there is any functions to handle this directly in pest ? I did some search on docs but couldn't find it.

jwalton512 commented 4 months ago

Not directly in pest, but this pest plugin adds some nice expectations for working with Laravel and Pest.