webmaesther/pest-plugin-contract

Pest plugin to define contract tests
236
Install
composer require webmaesther/pest-plugin-contract
PHP:^8.3
License:MIT
Last Updated:Sep 18, 2025
Links: GitHub  ·  Packagist
Maintainer: webmaesther

Contract Plugin for Pest PHP

This repository contains the Pest Plugin Contract.

If you want to start testing your application with Pest, visit the main Pest Repository.

Requirements

  • Pest v4

Installation

composer require webmaesther/pest-plugin-contract --dev

Usage

Define your contracts anywhere in your test folder in *Contract.php files.

contract('is string', function() {
    
    test('its type is string', function(mixed $value) {
    
        expect($value)->toBeString();
    })
});

Then you can use your contracts in any of your test files.


fulfill('is string')->with(['string']);

The fullfill function simply creates a describe block out of your contract closure, and includes it in your test file, exactly where you put it, as if you yourself would have written it. Thus, you can use any method on it that you would use on a describe block. Most notably you will need the with() method, which you should use to parametrize your tests with any Pest compatible dataset you like.

Related Packages

pestphp/pest-plugin-agent

AI agent verification plugin for Pest

60,329 6
nekofar/pest-plugin-mock-client

Pest Plugin for Mock HTTP client

22 1
quadraecom/pest-plugin-selectors

Add CSS selector-based testing capabilities to Pest

2,035 1
pestphp/pest-plugin-type-coverage

The Type Coverage plugin for Pest PHP.

4,810,598 36