jord-jd / phantomjs-laravel-testing
PhantomJS Laravel Testing
Fund package maintenance!
DivineOmega
Installs: 0
Dependents: 0
Suggesters: 0
Security: 0
Stars: 4
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/jord-jd/phantomjs-laravel-testing
Requires
- php: ^7.4 || ^8.0
- laravel/framework: ^8.0
- php-webdriver/webdriver: ^1.15
Requires (Dev)
- orchestra/testbench: ^6.3
- phpunit/phpunit: ^9.6
Replaces
This package is auto-updated.
Last update: 2026-02-14 23:35:20 UTC
README
The PhantomJS Laravel Testing package allows you to easily test your Laravel application's JavaScript functionality. It makes use of the PhantomJS headless browser to emulate how a real use would interact with your pages. If you have done regular Laravel testing, you'll be happy to know that this package attempts to match its syntax as much as possible.
💡 NOTE: If you're starting a new project, I recommend using Laravel Dusk instead. PhantomJS development is being suspended and will likely not receive any future updates.
Features
- Identical syntax to standard Laravel testing code where possible
- PhantomJS-powered headless browser allows full functionality testing, including JavaScript & AJAX
- Makes use of database transactions to prevent testing having permanent effects on the database
- Optional auto-start of PhantomJS if a
phantomjsbinary is available
Requirements
- Laravel 8.x
- PHP 7.4+
- A PhantomJS binary available in
PATHor viaPHANTOMJS_BIN(only needed if you usePhantomJSTestCase)
Installation
- Install via
composer require jord-jd/phantomjs-laravel-testing. - Add global middleware
\JordJD\PhantomJSLaravelTesting\Http\Middleware\GlobalMiddleware::classtoapp/Http/Kernel.phpmiddlewarearray.
Usage
Simply change your test classes to extend PhantomJSTestCase instead of TestCase, then run your unit tests as you normally do. PhantomJS will
automatically be started up when required.
By default, PhantomJSTestCase will try:
PHANTOMJS_BIN(full path tophantomjs)vendor/bin/phantomjsphantomjsinPATH
Set PJS_LT_DISABLE_AUTOSTART=1 to disable auto-start.
An example test case is shown below.
<?php use JordJD\PhantomJSLaravelTesting\Objects\PhantomJSTestCase; class ExampleTestCase extends PhantomJSTestCase { public function testGoogleShowsImFeelingLucky() { $this->visit('https://google.co.uk/'); $this->see('I\'m Feeling Lucky'); } public function testGoogleShowsImFeelingDucky() { $this->visit('https://google.co.uk/'); $this->see('I\'m Feeling Ducky'); } }