Skip to content

Commit

Permalink
Update DuskTestCase.php
Browse files Browse the repository at this point in the history
  • Loading branch information
realodix committed Jun 20, 2024
1 parent 46b1b46 commit 003c558
Showing 1 changed file with 19 additions and 19 deletions.
38 changes: 19 additions & 19 deletions tests/DuskTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,43 +5,43 @@
use Facebook\WebDriver\Chrome\ChromeOptions;
use Facebook\WebDriver\Remote\DesiredCapabilities;
use Facebook\WebDriver\Remote\RemoteWebDriver;
use Illuminate\Support\Collection;
use Laravel\Dusk\TestCase as BaseTestCase;
use Tests\Support\CreatesApplication;
use PHPUnit\Framework\Attributes\BeforeClass;

abstract class DuskTestCase extends BaseTestCase
{
use CreatesApplication;
use \Tests\Support\CreatesApplication;

/**
* Prepare for Dusk test execution.
*
* @beforeClass
*
* @return void
*/
public static function prepare()
#[BeforeClass]
public static function prepare(): void
{
static::startChromeDriver();
if (! static::runningInSail()) {
static::startChromeDriver();
}
}

/**
* Create the RemoteWebDriver instance.
*
* @return \Facebook\WebDriver\Remote\RemoteWebDriver
*/
protected function driver()
protected function driver(): RemoteWebDriver
{
$options = (new ChromeOptions)->addArguments([
'--disable-gpu',
'--headless',
'--window-size=1920,1080',
]);
$options = (new ChromeOptions)->addArguments(collect([
$this->shouldStartMaximized() ? '--start-maximized' : '--window-size=1920,1080',
])->unless($this->hasHeadlessDisabled(), function (Collection $items) {
return $items->merge([
'--disable-gpu',
'--headless=new',
]);
})->all());

return RemoteWebDriver::create(
'http://localhost:9515',
$_ENV['DUSK_DRIVER_URL'] ?? 'http://localhost:9515',
DesiredCapabilities::chrome()->setCapability(
ChromeOptions::CAPABILITY,
$options
ChromeOptions::CAPABILITY, $options
)
);
}
Expand Down

0 comments on commit 003c558

Please sign in to comment.