added various tests for playwright
This commit is contained in:
58
tests/Feature/SentryReportingTest.php
Normal file
58
tests/Feature/SentryReportingTest.php
Normal file
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use Symfony\Component\HttpKernel\Exception\HttpException;
|
||||
use Tests\TestCase;
|
||||
|
||||
class SentryReportingTest extends TestCase
|
||||
{
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
config(['sentry.dsn' => 'https://example@sentry.test/1']);
|
||||
}
|
||||
|
||||
public function test_reports_server_errors_to_sentry(): void
|
||||
{
|
||||
$fake = new class
|
||||
{
|
||||
public int $captured = 0;
|
||||
|
||||
public function captureException(mixed $exception = null): void
|
||||
{
|
||||
$this->captured++;
|
||||
}
|
||||
};
|
||||
|
||||
$this->app->instance('sentry', $fake);
|
||||
|
||||
$handler = $this->app->make(\App\Exceptions\Handler::class);
|
||||
|
||||
$handler->report(new \RuntimeException('boom'));
|
||||
|
||||
$this->assertSame(1, $fake->captured, 'Sentry should receive server errors');
|
||||
}
|
||||
|
||||
public function test_ignores_client_errors_for_sentry(): void
|
||||
{
|
||||
$fake = new class
|
||||
{
|
||||
public int $captured = 0;
|
||||
|
||||
public function captureException(mixed $exception = null): void
|
||||
{
|
||||
$this->captured++;
|
||||
}
|
||||
};
|
||||
|
||||
$this->app->instance('sentry', $fake);
|
||||
|
||||
$handler = $this->app->make(\App\Exceptions\Handler::class);
|
||||
|
||||
$handler->report(new HttpException(404));
|
||||
|
||||
$this->assertSame(0, $fake->captured, 'Sentry should ignore 4xx errors');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user