The Laravel Playwright package provides the boilerplate needed to begin testing your Laravel applications with Playwright quickly. This package will help you get all the necessary files installed, provides Laravel-specific helpers needed for testing, and gives you an example spec to demonstrate how to write end-to-end tests with Playwright:
test('Can create a new user and log them in', async ({ page }) => { const user1 = await login({ page }) expect(user1.name).toBeDefined() const user2 = await login({ page, attributes: { email: 'yoann@web-id.fr' } }) expect(user2.name).toEqual('Yoann') const user3 = await login({ page, attributes: { email: 'new@user.fr', name: 'New user' }, }) expect(user3.email).toEqual('new@user.fr')})
Depending on which Node package manager you are using in you project, you'll need to install Playwright using the npm init
command:
# NPMnpm init playwright@latest # Yarnyarn create playwright # PNPMpnpm create playwright
Main Features
- Simplified Setup: Automates the configuration process of setting up Playwright
- Boilerplate Generation: Provides an Artisan command to generate initial test setup and example specifications.
- Composer Integration: Installs easily as a development dependency via Composer, streamlining the setup process.
- Pre-configured Example Test: Includes a sample test to demonstrate usage
You can install this package via Composer using the following command:
composer require web-id/laravel-playwright --dev
Note: at the time of writing this package does not have any releases tagged. You'll have to change your "minimum-stability": "dev"
. You can learn more about this package, get full installation instructions, and view the source code on GitHub.