Download the PHP package franbarbalopez/laravel-playwright without Composer
On this page you can find all versions of the php package franbarbalopez/laravel-playwright. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download franbarbalopez/laravel-playwright
More information about franbarbalopez/laravel-playwright
Files in franbarbalopez/laravel-playwright
Package laravel-playwright
Short Description A Laravel Package to use Laravel testing functionality into Playwright
License MIT
Informations about the package laravel-playwright
Laravel Playwright
A Laravel package that integrates Laravel testing functionality with Playwright. Use Laravel's powerful factories, authentication and other features directly in your Playwright tests.
Installation
[!WARNING] ALPHA RELEASE – This package is in the alpha phase, meaning its structure may change significantly. It is recommended for internal testing and controlled environments only.
Requirements
- PHP 8.2+
- Laravel 11+
Via composer
Setup
After installing the package, run the installation command:
This will:
- Install Playwright if it's not already installed
- Ask for your Playwright tests directory location
- Copy the necessary JavaScript helper files
[!IMPORTANT] After installation, you must uncomment and update the
baseURL
in your playwright config file.
Usage
Factories
Creating Models using Factories
You may create a collection of many models using the count
property:
Applying States
Overriding Attributes
Factory Relationships
Has Many Relationships
You may override attributes of the related model using attributes
property inside the relationship object:
If you want the posts to be retrieved with the parent model you should use the load
property:
Belongs To Relationships
You could also use an id of a model generated previously:
Many to Many Relationships
Pivot Table Attributes
Polymorphic Relationships
Morph To Relationships
As in Laravel you could use here the relationships way with the for
method.
Polymorphic Many to Many Relationships
You can create this relationships using the has
and hasAttached
methods way as if we were doing this on Laravel.
CSRF Token
Authentication
Artisan Commands
You can execute any Laravel Artisan command from your Playwright tests using the artisan
endpoint. This is useful for resetting the database, clearing caches, or running any custom Artisan command during your end-to-end tests.
Usage Example (JavaScript)
command
: The Artisan command you want to run (e.g.,migrate:fresh
,cache:clear
,route:list
).parameters
: (Optional) An object with any parameters or options you want to pass to the command.
Example: List all routes in JSON format
Error Handling
If you try to run a non-existent command, the endpoint will return a 500 error.