Skip to content

Commit

Permalink
Fix randomly failing test by blocking favicon
Browse files Browse the repository at this point in the history
  • Loading branch information
JeppeKnockaert authored and freekmurze committed Aug 22, 2024
1 parent e007bf0 commit 601f275
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions tests/BrowsershotTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1004,7 +1004,9 @@

$this->expectException(ProcessFailedException::class);

$instance = Browsershot::url('https://example.com');
// Block the favicon request to prevent randomness in the output.
$instance = Browsershot::url('https://example.com')
->blockUrls(['https://example.com/favicon.ico']);

try {
$instance->save($targetPath);
Expand All @@ -1014,7 +1016,14 @@
expect($output)->not()->toBeNull();
expect($output)->toBeInstanceOf(ChromiumResult::class);
expect($output->getException())->not()->toBeEmpty();
expect($output->getConsoleMessages())->toBe([]);
expect($output->getConsoleMessages())->toBe([
[
'type' => 'error',
'message' => 'Failed to load resource: net::ERR_FAILED',
'location' => ['url' => 'https://example.com/favicon.ico'],
'stackTrace' => [['url' => 'https://example.com/favicon.ico']],
],
]);
expect($output->getRequestsList())->toMatchArray([[
'url' => 'https://example.com/',
]]);
Expand Down

0 comments on commit 601f275

Please sign in to comment.