Skip to content

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

bash
composer remove laravel/dusk
composer require --dev gawrys/dawn
vendor/bin/playwright-install --browsers

Node.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:

diff
-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
<?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:

xml
<testsuite name="Browser">
    <directory>tests/Browser</directory>
</testsuite>
bash
php artisan test --testsuite=Browser
# or: vendor/bin/phpunit --testsuite Browser

Serve 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-browser browse() 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 @name selectors.
  • DatabaseMigrations / DatabaseTruncation.
  • Screenshot (tests/Browser/screenshots) and console log (tests/Browser/console) paths - CI artifact globs keep working.

Pre-flight checklist

  1. Dawn covers ~95% of the Dusk Browser API. 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 clear UnsupportedDuskMethod, never a wrong result.
  2. Using RefreshDatabase in a browser test? It never truly worked under Dusk either - Dawn fails fast with instructions to switch to DatabaseMigrations.
  3. CI: replace ChromeDriver setup with vendor/bin/playwright-install --with-deps and drop any php artisan dusk:chrome-driver steps.

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.

Released under the MIT License. Not affiliated with Laravel.