pestphp / pestphp/pest

[Bug]: Hooks for before/after the entire suite

Open
#1,589 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
PHP
Stars
11.7k
Forks
538
Avg merge
4d 11h
Merged PRs (30d)
8

Description

What Happened

Docs say

In addition, you can define global hooks that will run before or after your entire test suite, regardless of the folder or group.

but after wasting a few hours I wasn't able to find a single working solution for it, much less a simple and straightforward one for such a primitive requirement.

https://pestphp.com/docs/global-hooks#:~:text=In%20addition%2C%20you%20can%20define%20global%20hooks%20that%20will%20run%20before%20or%20after%20your%20entire%20test%20suite%2C%20regardless%20of%20the%20folder%20or%20group.

How to Reproduce

Just try to run a hook before/after running the entire suite.

Sample Repository

No response

Pest Version

4.1.3

PHP Version

8.3.27

Operation System

macOS

Notes

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the global-hooks documentation and reproduce the reported behavior using Pest 4.1.3 on PHP 8.3.27. Trace how suite-wide hooks are registered and executed, then verify that a before or after hook runs for the entire suite regardless of folder or group and that the documentation describes the working solution.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
testing
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.