45 lines
1.3 KiB
PHP
45 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace Tests;
|
|
|
|
use Laravel\Dusk\TestCase as BaseTestCase;
|
|
use Facebook\WebDriver\Chrome\ChromeOptions;
|
|
use Facebook\WebDriver\Remote\RemoteWebDriver;
|
|
use Facebook\WebDriver\Remote\DesiredCapabilities;
|
|
|
|
abstract class DuskTestCase extends BaseTestCase
|
|
{
|
|
/**
|
|
* Prepare for Dusk test execution.
|
|
*
|
|
* @beforeClass
|
|
*/
|
|
public static function prepare(): void
|
|
{
|
|
if (! static::runningInSail()) {
|
|
static::startChromeDriver();
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Create the RemoteWebDriver instance.
|
|
*/
|
|
protected function driver(): RemoteWebDriver
|
|
{
|
|
$options = (new ChromeOptions)->addArguments(collect([
|
|
$this->shouldStartMaximized() ? '--start-maximized' : '--window-size=1920,1080',
|
|
'--disable-gpu',
|
|
'--headless=new',
|
|
'--no-sandbox',
|
|
'--disable-dev-shm-usage',
|
|
])->unless(static::runningInSail(), function (collect $arguments) {
|
|
return $arguments->push('--disable-smooth-scrolling');
|
|
})->all());
|
|
|
|
return RemoteWebDriver::create(
|
|
$_ENV['DUSK_DRIVER_URL'] ?? env('DUSK_DRIVER_URL') ?? 'http://localhost:9515',
|
|
DesiredCapabilities::chrome()->setCapability(ChromeOptions::CAPABILITY, $options)
|
|
);
|
|
}
|
|
}
|