pestphp / pestphp/pest

[Bug]: pest4 - The test directory [tests/] does not exist

Open
#1,444 5 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

Pest does not work after upgrading from pest3 to pest4:

$ vendor/bin/pest --help

   Pest\Exceptions\FatalException

  The test directory [/project/tests/] does not exist.

  at vendor/pestphp/pest/src/Bootstrappers/BootFiles.php:45
     41▕         $rootPath = TestSuite::getInstance()->rootPath;
     42▕         $testsPath = $rootPath.DIRECTORY_SEPARATOR.testDirectory();
     43▕
     44▕         if (! is_dir($testsPath)) {
  ➜  45▕             throw new FatalException(sprintf('The test directory [%s] does not exist.', $testsPath));
     46▕         }
     47▕
     48▕         foreach (self::STRUCTURE as $filename) {
     49▕             $filename = sprintf('%s%s%s', $testsPath, DIRECTORY_SEPARATOR, $filename);


$ vendor/bin/pest --init

   Pest\Exceptions\FatalException

  The test directory [/project/tests/] does not exist.

  at vendor/pestphp/pest/src/Bootstrappers/BootFiles.php:45
     41▕         $rootPath = TestSuite::getInstance()->rootPath;
     42▕         $testsPath = $rootPath.DIRECTORY_SEPARATOR.testDirectory();
     43▕
     44▕         if (! is_dir($testsPath)) {
  ➜  45▕             throw new FatalException(sprintf('The test directory [%s] does not exist.', $testsPath));
     46▕         }
     47▕
     48▕         foreach (self::STRUCTURE as $filename) {
     49▕             $filename = sprintf('%s%s%s', $testsPath, DIRECTORY_SEPARATOR, $filename);
How to Reproduce
  1. Delete tests directory - rm -rf tests
  2. Run pest binary - vendor/bin/pest --help
Sample Repository

No response

Pest Version

4.0.0

PHP Version

8.4.10

Operation System

macOS, Linux

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 vendor/pestphp/pest/src/Bootstrappers/BootFiles.php at the reported directory check and trace how vendor/bin/pest --help and --init reach it. Reproduce the failure after removing tests/, then add regression coverage for both commands. Done means these commands no longer fail solely because tests/ is absent.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.