Skip to content

Commit

Permalink
Move expectException to cover only the expected throwing method
Browse files Browse the repository at this point in the history
Make the timeout test more robust by moving the `expectException`
call immediately before the method that is expected to throw
(and after all the setup methods). This will provide better
long-term confidence/guarantees that the test is working
as expected and only throwing during the final `->getContent`
call.
  • Loading branch information
acoulton committed Feb 2, 2024
1 parent 2465c89 commit 7317f27
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion tests/ChromeDriverConnectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,12 @@ public function testTimeoutExceptionIfResponseBlocked()
'socketTimeout' => 1,
];
$this->driver = new ChromeDriver('http://localhost:9222', null, 'about:blank', $options);
$this->expectException(TimeoutException::class);
$script = "confirm('Is the browser blocked? (yes, it is)');";
$this->driver->visit('about:blank');
$this->driver->evaluateScript($script);

// Content read is necessary to trigger timeout.
$this->expectException(TimeoutException::class);
$this->driver->getContent();
}

Expand Down

0 comments on commit 7317f27

Please sign in to comment.