Download the PHP package hyvor/laravel-playwright without Composer
On this page you can find all versions of the php package hyvor/laravel-playwright. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download hyvor/laravel-playwright
More information about hyvor/laravel-playwright
Files in hyvor/laravel-playwright
Package laravel-playwright
Short Description Laravel and Playwright E2E Testing
License MIT
Informations about the package laravel-playwright
Laravel Playwright
This repository contains a Laravel and a Playwright library to help you write E2E tests for your Laravel application using Playwright. It adds a set of endpoints to your Laravel application to allow Playwright to interact with it. You can do the following from your Playwright tests:
- Run artisan commands
- Create models using factories
- Run database queries
- Run PHP functions
- Update Laravel config while a test is running (until the test ends and calls
tearDown). - Registering a boot function to run on each Laravel request. You can use this feature to mock a service dependency, for example.
- Traveling to a specific time in the application during the test
Installation
On Laravel side, install the package via composer:
On Playwright side, install the package via npm:
Laravel Config
You can configure the routes by adding an e2e key to your config/app.php file. The following options are available (default values are shown):
Playwright Config
Set use.laravelBaseUrl in your playwright.config.ts file to the base URL of your testing endpoints. This is the URL of your application + the prefix you set in Laravel config.
If you use Typescript, include the LaravelOptions type in the defineConfig function.
Setting up tests
In your Playwright tests, swap the test import from @playwright/test to @hyvor/laravel-playwright.
Note: In practise, it is not recommended to import from
@hyvor/laravel-playwrightdirectly on every test file, if you have many. Instead, create your own test fixture extendingtestfrom@hyvor/laravel-playwrightand import that fixture in your tests.
Basic Usage
Dynamic Configuration
You can update Laravel config for ALL subsequent requests until the test ends.