Skip to content

Conversation

@Willem-Jaap
Copy link
Contributor

@Willem-Jaap Willem-Jaap commented Dec 18, 2025

Add file-level only() function

Adds a new global only() function to mark all tests in a file to run exclusively, complementing the existing test-level ->only() method.

Usage

<?php

only(); // Mark all tests in this file to run exclusively

test('first test', function () {
    expect(true)->toBeTrue();
});

test('second test', function () {
    expect(1 + 1)->toBe(2);
});

Benefits

  • Quickly run all test in a file without having to add the entire path to pest cmd
  • Avoid chaining ->only() to every test in a file

Docs

Related docs pr: pestphp/docs#345

@Willem-Jaap
Copy link
Contributor Author

I've considered the following as an alternative / additional API:

pest()->only();

Where the method is implemented on the configuration class instead of globally.

Open to suggestions!

@nunomaduro
Copy link
Member

Can you make a pull request that adds "pest()->only();"?

@Willem-Jaap
Copy link
Contributor Author

Willem-Jaap commented Dec 30, 2025

Yes, definitely:
pest: #1598 & docs: pestphp/docs#346

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants