Skip to content

Commit 7073f79

Browse files
committed
chore: fixes tests
1 parent 8df0a27 commit 7073f79

3 files changed

Lines changed: 32 additions & 13 deletions

File tree

composer.json

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,15 @@
4242
"ext-pcntl": "*",
4343
"ext-posix": "*",
4444

45-
"laravel/framework": "^11.31",
46-
"laravel/tinker": "^2.9",
47-
"livewire/livewire": "^3.5",
48-
"fakerphp/faker": "^1.23",
49-
"laravel/pail": "^1.1",
50-
"laravel/pint": "^1.13",
51-
"laravel/sail": "^1.26",
52-
"mockery/mockery": "^1.6",
53-
"nunomaduro/collision": "^8.1",
45+
"laravel/framework": "^11.45.1",
46+
"laravel/tinker": "^2.10.1",
47+
"livewire/livewire": "^3.6.3",
48+
"fakerphp/faker": "^1.24.1",
49+
"laravel/pail": "^1.2.3",
50+
"laravel/pint": "^1.22.1",
51+
"laravel/sail": "^1.43.1",
52+
"mockery/mockery": "^1.6.12",
53+
"nunomaduro/collision": "^8.8.1",
5454
"pestphp/pest-plugin-laravel": "^4.0"
5555
},
5656
"minimum-stability": "dev",
@@ -77,7 +77,7 @@
7777
"rector --dry-run",
7878
"pint --test"
7979
],
80-
"test:unit": "pest --parallel --coverage --exactly=83.2",
80+
"test:unit": "pest --parallel --coverage --exactly=83.6",
8181
"test:types": "phpstan",
8282
"test": [
8383
"@test:lint",

src/Playwright/Locator.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44

55
namespace Pest\Browser\Playwright;
66

7+
use Exception;
78
use Generator;
89
use Pest\Browser\Playwright\Concerns\InteractsWithPlaywright;
910
use Pest\Browser\Support\Selector;
1011
use PHPUnit\Framework\ExpectationFailedException;
1112
use RuntimeException;
12-
use WebSocket\TimeoutException;
1313

1414
/**
1515
* @internal
@@ -284,12 +284,18 @@ public function getAttribute(string $name): ?string
284284
*/
285285
public function waitFor(?array $options = null): void
286286
{
287+
set_error_handler(static fn (): false => false);
288+
287289
try {
288290
$response = $this->sendMessage('waitForSelector', $options ?? []);
289291

290292
$this->processVoidResponse($response);
291-
} catch (TimeoutException) {
292-
throw new ExpectationFailedException('Element not found.');
293+
} catch (Exception $e) {
294+
if ($e->getMessage() === 'Client read timeout') {
295+
throw new ExpectationFailedException('Element not found.');
296+
}
297+
} finally {
298+
restore_error_handler();
293299
}
294300
}
295301

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use PHPUnit\Framework\ExpectationFailedException;
6+
7+
it('throws an expectation failed exception when the element is not visible', function (): void {
8+
$page = page()->goto('/test/element-tests');
9+
10+
$locator = $page->locator('input[name="404"]');
11+
12+
$locator->waitFor();
13+
})->throws(ExpectationFailedException::class);

0 commit comments

Comments
 (0)