PHPackages                             divineomega/phantomjs-laravel-testing - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Testing &amp; Quality](/categories/testing)
4. /
5. divineomega/phantomjs-laravel-testing

Abandoned → [jord-jd/phantomjs-laravel-testing](/?search=jord-jd%2Fphantomjs-laravel-testing)Library[Testing &amp; Quality](/categories/testing)

divineomega/phantomjs-laravel-testing
=====================================

PhantomJS Laravel Testing

v1.0(9y ago)450LGPL-3.0PHP

Since Feb 16Pushed 2mo ago1 watchersCompare

[ Source](https://github.com/Jord-JD/PhantomJS-Laravel-Testing)[ Packagist](https://packagist.org/packages/divineomega/phantomjs-laravel-testing)[ Docs](https://github.com/DivineOmega/PhantomJS-Laravel-Testing)[ RSS](/packages/divineomega-phantomjs-laravel-testing/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (2)Dependencies (4)Versions (2)Used By (0)

PhantomJS Laravel Testing
=========================

[](#phantomjs-laravel-testing)

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](https://laravel.com/docs/master/dusk) instead. [PhantomJS development is being suspended](https://github.com/ariya/phantomjs/issues/15344) and will likely not receive any future updates.**

Features
--------

[](#features)

- Identical syntax to standard Laravel testing code where possible
- PhantomJS-powered headless browser allows full functionality testing, including JavaScript &amp; AJAX
- Makes use of database transactions to prevent testing having permanent effects on the database
- Optional auto-start of PhantomJS if a `phantomjs` binary is available

Requirements
------------

[](#requirements)

- Laravel 8.x
- PHP 7.4+
- A PhantomJS binary available in `PATH` or via `PHANTOMJS_BIN` (only needed if you use `PhantomJSTestCase`)

Installation
------------

[](#installation)

1. Install via `composer require jord-jd/phantomjs-laravel-testing`.
2. Add global middleware `\JordJD\PhantomJSLaravelTesting\Http\Middleware\GlobalMiddleware::class` to `app/Http/Kernel.php` `middleware` array.

Usage
-----

[](#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 to `phantomjs`)
- `vendor/bin/phantomjs`
- `phantomjs` in `PATH`

Set `PJS_LT_DISABLE_AUTOSTART=1` to disable auto-start.

An example test case is shown below.

```
