Summer Sale! All accounts are 50% off this week.

YakutD's avatar

How to testing render from Exception Handler?

Hello. I make my Exception Handler return specific Inertia component if http error occur. But how can I write pest test for it? This is my code, and it works fine:

        $exception = new HttpException($allowedHttpErrorStatus);
        $response = app(Handler::class)->render(request(), $exception);

        $this->assertEquals($response->getStatusCode(), $allowedHttpErrorStatus);

But I dont know how to check Inertia component rendered. $response has not assertInertia method.

0 likes
1 reply
YakutD's avatar
YakutD
OP
Best Answer
Level 1

Well in my case such construction works:

$response->original->getData()['page'];

Please or to participate in this conversation.