Migrating from Dusk
Switching an existing Dusk suite to Dawn takes a few minutes. Your test bodies do not change.
Step 1 - swap the packages
composer remove laravel/dusk
composer require --dev gawrys/dawn
vendor/bin/playwright-install --browsersNode.js 20+ must be available (node -v). The last command installs the Playwright engine and downloads the browser binaries.
Step 2 - swap the base class
Dusk's installer generated tests/DuskTestCase.php with WebDriver plumbing. Replace it:
-use Facebook\WebDriver\Chrome\ChromeOptions;
-use Facebook\WebDriver\Remote\DesiredCapabilities;
-use Facebook\WebDriver\Remote\RemoteWebDriver;
-use Laravel\Dusk\TestCase as BaseTestCase;
+use Dawn\TestCase as BaseTestCase;
abstract class DuskTestCase extends BaseTestCase
{
use CreatesApplication; // Laravel 10 only
- public static function prepare(): void
- {
- static::startChromeDriver();
- }
-
- protected function driver(): RemoteWebDriver
- {
- return RemoteWebDriver::create(
- 'http://localhost:9515', DesiredCapabilities::chrome()->setCapability(
- ChromeOptions::CAPABILITY, (new ChromeOptions)->addArguments([
- '--disable-gpu', '--headless=new', '--window-size=1920,1080',
- ])
- )
- );
- }
}The whole class body after migration:
<?php
namespace Tests;
use Dawn\TestCase as BaseTestCase;
abstract class DuskTestCase extends BaseTestCase
{
// Laravel 10 only: use CreatesApplication;
}Step 3 - run the suite
php artisan dusk was a Dusk command; run the suite with PHPUnit instead. Register the suite once in phpunit.xml:
<testsuite name="Browser">
<directory>tests/Browser</directory>
</testsuite>php artisan test --testsuite=Browser
# or: vendor/bin/phpunit --testsuite BrowserServe your app as you did for Dusk (php artisan serve, Valet, Sail, ...); Dawn reads the base URL from APP_URL, exactly like Dusk.
That's the whole migration.
What keeps working without changes
- Every test body:
visit,type,press,click,waitFor*,assert*,within,loginAs, multi-browserbrowse()callbacks. use Laravel\Dusk\Browser;imports and closure type hints - Dawn aliases that class name automatically when laravel/dusk is absent.dusk="..."HTML attributes and@nameselectors.DatabaseMigrations/DatabaseTruncation.- Screenshot (
tests/Browser/screenshots) and console log (tests/Browser/console) paths - CI artifact globs keep working.
Pre-flight checklist
- Dawn covers ~95% of the Dusk
BrowserAPI. Grep your suite for the few unsupported methods (marked ⛔ in the compatibility table) -maximize/move,tinker/stop, and the JavaScript-dialog methods (acceptDialog,dismissDialog,typeInDialog,waitForDialog,assertDialogOpened). Any call to them throws a clearUnsupportedDuskMethod, never a wrong result. - Using
RefreshDatabasein a browser test? It never truly worked under Dusk either - Dawn fails fast with instructions to switch toDatabaseMigrations. - CI: replace ChromeDriver setup with
vendor/bin/playwright-install --with-depsand drop anyphp artisan dusk:chrome-driversteps.
Behavioural notes
Actions auto-wait for actionability (up to Dusk's default 5 seconds) before failing, which strictly reduces flakiness compared to Dusk's act-immediately model. Assertions remain point-in-time, exactly like Dusk. The full list of known divergences is at the bottom of the compatibility table.