Download the PHP package skylerkatz/phpunit-plugin-browser without Composer

On this page you can find all versions of the php package skylerkatz/phpunit-plugin-browser. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package phpunit-plugin-browser

PHPUnit Browser Plugin

A PHPUnit extension for browser testing powered by Playwright.

Attribution: This package is a port of pestphp/pest-plugin-browser by Nuno Maduro and the Pest team. Full credit goes to the original authors for the API design and Playwright integration. This package adapts that work for use with PHPUnit directly.

Requirements

Installation

Install via Composer:

Install Playwright browsers:

PHPUnit Configuration

Register the extension in your phpunit.xml:

You can pass optional parameters directly in the bootstrap:

Writing Tests

Extend BrowserTestCase and use $this->visit() to open a page:

Basic Example

Form Interactions

Dropdowns, Checkboxes, and Radio Buttons

Device Emulation

Available devices include DESKTOP, MOBILE, MACBOOK_16, IPHONE_15_PRO, IPAD_PRO, PIXEL_8, GALAXY_S24_ULTRA, SURFACE_PRO_9, and more.

Dark Mode

Screenshot Assertions

JavaScript Execution

Multiple URLs

iFrames

Configuration

Environment Variables

Variable Description
BROWSER_HEADED Show the browser window (true/false)
BROWSER_DEBUG Enable debug mode on failures
BROWSER_DIFF Show diffs on screenshot failures
BROWSER_DARK Use dark color scheme
BROWSER_LIGHT Use light color scheme
BROWSER_TYPE Browser: chrome, firefox, or safari
BROWSER_TIMEOUT Assertion timeout in milliseconds
BROWSER_HOST Playwright server host

Runtime Configuration

Configure globally in your test's setUp method:

Available Assertions

Element Assertions

Method Description
assertTitle($title) Assert page title matches exactly
assertTitleContains($text) Assert page title contains text
assertSee($text) Assert text is visible on page
assertDontSee($text) Assert text is not visible
assertSeeIn($selector, $text) Assert text is visible within element
assertDontSeeIn($selector, $text) Assert text is not visible within element
assertPresent($selector) Assert element exists in DOM
assertMissing($selector) Assert element does not exist in DOM
assertVisible($selector) Assert element is visible
assertEnabled($selector) Assert element is enabled
assertDisabled($selector) Assert element is disabled
assertChecked($selector) Assert checkbox is checked
assertSelected($selector, $value) Assert select has value
assertValue($selector, $value) Assert input has value
assertAttribute($selector, $attr, $value) Assert element attribute value
assertAriaAttribute($selector, $attr, $value) Assert ARIA attribute value
assertDataAttribute($selector, $attr, $value) Assert data attribute value
assertSourceHas($code) Assert page source contains string
assertSourceMissing($code) Assert page source does not contain string
assertSeeLink($url) Assert link is visible
assertDontSeeLink($url) Assert link is not visible

URL Assertions

Method Description
assertUrlIs($url) Assert full URL matches (supports * wildcards)
assertUrlContains($text) Assert URL contains text
assertQueryStringHas($key, $value) Assert query string parameter

Screenshot Assertions

Method Description
assertScreenshotMatches($fullPage) Visual regression test against baseline

Available Interactions

Method Description
click($selector) Click an element
press($text) Press a button by text
type($selector, $value) Type into an input
typeSlowly($selector, $value) Type character by character
fill($selector, $value) Fill an input (clears first)
clear($selector) Clear an input
append($selector, $value) Append text to an input
select($selector, $value) Select a dropdown option
check($selector) Check a checkbox
uncheck($selector) Uncheck a checkbox
radio($selector, $value) Select a radio button
hover($selector) Hover over an element
rightClick($selector) Right-click an element
drag($from, $to) Drag and drop
keys($selector, $keys) Send keyboard input
attach($selector, $path) Upload a file
script($js) Execute JavaScript

Migrating from Pest

This package includes a CLI tool to convert Pest test files to PHPUnit. It handles structural transformations (test()/it() to class methods, expect() chains to PHPUnit assertions, beforeEach/afterEach to setUp/tearDown, etc.) and converts visit() calls to $this->visit().

What gets converted

Pest PHPUnit
test('name', function () { ... }) public function test_name(): void { ... }
it('does something', function () { ... }) public function test_it_does_something(): void { ... }
describe('group', ...) Method name prefix (e.g. test_group_name)
beforeEach(function () { ... }) setUp() with parent::setUp()
afterEach(function () { ... }) tearDown() with parent::tearDown()
uses(RefreshDatabase::class) use RefreshDatabase trait
visit('/') $this->visit('/')
expect($val)->toBe('foo') $this->assertSame('foo', $val)
expect($val)->not->toBeNull() $this->assertNotNull($val)
->skip() $this->markTestSkipped()
->todo() $this->markTestIncomplete()

License

MIT


All versions of phpunit-plugin-browser with dependencies

PHP Build Version
Package Version
Requires php Version ^8.3
ext-sockets Version *
amphp/amp Version ^3.1.1
amphp/http-server Version ^3.4.4
amphp/websocket-client Version ^2.0.2
nikic/php-parser Version ^5.0
nunomaduro/collision Version ^8.9
phpunit/phpunit Version ^11.0
symfony/process Version ^7.4.5|^8.0.5
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package skylerkatz/phpunit-plugin-browser contains the following files

Loading the files please wait ...