Introduction
Write readable Pest tests as executable behaviour specifications.
Pest Flow adds a small behaviour-driven vocabulary to ordinary Pest tests. Use it to group a capability into business rules, describe each rule with executable scenarios, and organize setup, actions, and expectations into steps.
Feature
└── Rule
└── Scenario
├── Given
├── When
└── Then
Pest still discovers and runs each scenario as a normal test. You keep Pest’s assertions, lifecycle hooks, test runner, and failure output. Pest Flow records features, rules, scenarios, steps, identifiers, source locations, execution statuses, durations, and captured exceptions for PHP code to inspect.
Choose a starting point
Quickstart
Install Pest Flow and get your first scenario running.
Walkthroughs
Build a complete feature test and inspect its registry data.
DSL reference
Look up every DSL function, placement rule, and runtime behavior.
Registry reference
Explore the node types, identifiers, source locations, and timing.
How a scenario reads
feature('Checkout', function (): void {
rule('Discounts reduce the order total', function (): void {
scenario('Applies a fixed discount', function (): void {
given('an order worth 120 dollars', function (): void {
$this->subtotal = 120;
});
when('a discount of 12 dollars is applied', function (): void {
$this->total = $this->subtotal - 12;
});
then('the total is 108 dollars', function (): void {
expect($this->total)->toBe(108);
});
});
});
});
Each step runs in order on the same Pest test context. The values set in Given are available in When and Then, and an ordinary Pest expectation determines whether the scenario passes.
Learn in order
Install and run a scenario
Follow the quickstart to add the package and run a Pest test.
Walk through a complete example
The first scenario walkthrough explains the feature, rule, scenario, and step callbacks line by line.
Look up the API
Use the DSL reference for function behavior and core concepts for how Pest Flow fits into Pest.
Inspect discovered behavior
Follow the registry walkthrough and the registry reference.