Skip to content

Feature Request: Add option to exclude directories from test discovery (e.g., vendor/) #344

@ThePrincelle

Description

@ThePrincelle

Description

When working with a monorepo or a project where Laravel is in a subdirectory, the extension discovers and lists tests from the vendor/ directory, which pollutes the Test Explorer with hundreds of irrelevant tests from third-party packages.

Current Behavior

The extension scans all *Test.php files in the workspace, including those inside vendor/. There is no way to exclude specific directories from test discovery.

Expected Behavior

Provide a configuration option to exclude directories from test discovery, similar to the old phpunit.files option that existed in v2.x.

Suggested Solution

Add a new setting like:

json{
    "phpunit.exclude": ["**/vendor/**"]
}

Or bring back the phpunit.files option:

json{
    "phpunit.files": "laravel/tests/**/*Test.php"
}

Workarounds Attempted (None Worked)

  • files.exclude: Does not affect test discovery
  • search.exclude: Does not affect test discovery
  • files.watcherExclude: Does not affect test discovery
  • phpunit.files: Option no longer exists in v3.x
  • phpunit.paths: Only for local/remote path mapping, not filtering

Environment

  • Extension version: 3.7.10
  • VS Code version: 1.96
  • OS: macOS

Project Structure

/my-project
├── devbox.json
├── laravel/
│   ├── vendor/          ← Tests here should be ignored
│   ├── tests/           ← Only these tests should be discovered
│   │   ├── Unit/
│   │   └── Feature/
│   └── phpunit.xml
└── other-folders/

Current Configuration

json{
    "phpunit.command": "devbox",
    "phpunit.phpunit": "run test:laravel",
    "phpunit.args": []
}

Additional Context

The only current workaround is to open the laravel/ subdirectory directly in VS Code, which is not ideal for monorepo workflows where you need access to other folders.

Thank you for this great extension!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions