Skip to content

Comments

Dusk to Pest Browser Tests Converter#449

Open
Korko wants to merge 1 commit into1.8.x-laravel12from
shift-163241
Open

Dusk to Pest Browser Tests Converter#449
Korko wants to merge 1 commit into1.8.x-laravel12from
shift-163241

Conversation

@Korko
Copy link
Owner

@Korko Korko commented Dec 11, 2025

This pull request includes the changes for converting your Laravel Dusk tests to Pest Browser Tests. Feel free to commit any additional changes to the shift-163241 branch.

Before merging, you need to:

  • Checkout the shift-163241 branch
  • Review all pull request comments for additional changes
  • Run composer update (if the scripts fail, try with --no-scripts)
  • Run npm update
  • Run your browser tests php artisan test

If you get stuck, never hesitate to email support. If you need more help with your upgrade, check out the Human Shifts.

@Korko
Copy link
Owner Author

Korko commented Dec 11, 2025

ℹ️ Pest Browser Testing is built on top of Playwright. While Shift added this as an NPM dependency, you will need to run npx playwright install to install the necessary drivers within your local environment.

@Korko
Copy link
Owner Author

Korko commented Dec 11, 2025

⚠️ Dusk Pages are not available within Pest Browser Testing. You will need to review your Page classes and inline the code to their respective uses within your new Pest tests.

@Korko
Copy link
Owner Author

Korko commented Dec 11, 2025

ℹ️ To run your browser tests, Dusk required you to run an instance of your application in the background. With Pest Browser Testing, your tests run your application directly. This allows you to leverage the full power of Laravel's testing layer, such as refreshing the database and built-in faking.

It also allows you to more easily run your browser tests. Often you may simply run vendor/bin/pest tests/Browser. You may review the documentation for running your browser tests in CI.

@Korko
Copy link
Owner Author

Korko commented Dec 11, 2025

ℹ️ Since Dusk ran separately from your application, your Dusk tests did not use the common testing traits for managing services. For example, the RefreshDatabase trait to manage your testing database and seeders.

Your Pest Browser tests will likely need to use these traits. You may quickly configure all your browser tests to use them within your tests/Pest.php file. For example, to add the RefreshDatabase trait:

pest()->extend(TestCase::class)->use(RefreshDatabase::class)->in('Browser');

@Korko
Copy link
Owner Author

Korko commented Dec 11, 2025

⚗️ This Shift is still being refined. Please report any issues or suggestions to shift@laravelshift.com. Your feedback is what helps improve the experience for everyone.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants