Installation
Requirements
Before installing Pest Plugin Bridge, ensure you have:
| Requirement | Version |
|---|---|
| PHP | 8.3+ |
| Pest | 4.0+ |
| Composer | 2.0+ |
| Node.js | 18+ |
Step 1: Install the Plugin
Install the plugin via Composer:
composer require testflowlabs/pest-plugin-bridge --devThis will also install the required pestphp/pest-plugin-browser dependency.
Step 2: Install Playwright
The browser testing functionality uses Playwright under the hood. Install it via npm:
npm install playwright
npx playwright install chromiumInstalling All Browsers
If you want to test across multiple browsers, install them all:
npx playwright installThis installs Chromium, Firefox, and WebKit.
Step 3: Configure the External URL
Configure in your tests/Pest.php file:
<?php
use TestFlowLabs\PestPluginBridge\Bridge;
Bridge::setDefault('http://localhost:5173');Step 4: Verify Installation
Create a simple test to verify everything works:
// tests/Browser/ExampleTest.php
<?php
test('can visit external frontend', function () {
$this->bridge('/')
->assertSee('Welcome');
});Run it:
./vendor/bin/pest tests/Browser/ExampleTest.phpAutomatic Server Management
With ->serve() configuration, the frontend starts automatically when tests run. No need to manually start servers!
// tests/Pest.php
Bridge::setDefault('http://localhost:3000')
->serve('npm run dev', cwd: '../frontend')
->readyWhen('ready|localhost');Project Structure
After installation, your project should look like this:
your-project/
├── tests/
│ ├── Pest.php # Plugin configuration
│ ├── Browser/
│ │ └── ExampleTest.php # Browser tests
│ ├── Feature/
│ └── Unit/
├── composer.json
└── package.json # Playwright dependencyTroubleshooting
Playwright Not Found
If you get "Playwright is not installed" error:
npm install playwright
npx playwright install chromiumBrowser Launch Fails
On Linux servers, you may need additional dependencies:
npx playwright install-deps chromiumConnection Refused
Ensure your frontend is running and accessible:
curl http://localhost:5173