3.10.x: failure messages no longer appear in the test file when Pest reports relative paths (regression from 3.9.40)
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 76/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- php, typescript, vscode
Research direction
Read TestResultObserver.message() and the test added in commit a6cf35b that covers absolute paths. Trace how relative paths in Pest's details become Uri.file() locations and stack frames; add coverage for tests/Feature/SomeTest.php and resolve it against the project root or cwd. Done when the inline failure message appears at the test location for relative paths while inherited and trait method locations still work.
Written by the indexing model from the issue text.
Description
What happened?
Since updating from 3.9.40 to 3.10.1, failure messages are no longer shown inline in the test file. The test is marked as failed, but the message is not attached to the test file. Downgrading to 3.9.40 brings the inline message back. This is still the case on main (4b334f8).
Pest prints the stack frames in details relative to the project root (tests/Feature/SomeTest.php:146).
Cause: this was introduced in a6cf35b ("fix: point failures of inherited and trait test methods to their declaring file"), which changed the message location in TestResultObserver.message() from the test item's URI to the matched frame's path:
message.location = new Location(
location ? Uri.file(location.file) : test.uri,
new Range(new Position(line, 0), new Position(line, 0)),
);
location.file is the relative path from Pest. Uri.file() turns it into /tests/Feature/SomeTest.php at the filesystem root, a file that does not exist. The test added in that commit only covers absolute paths (/project/tests/TestCase.php). phpunit.paths cannot help, because it only rewrites absolute paths, and expandRelative() only handles paths starting with ./. The stack frames (TestMessageStackFrame) are built from the same relative paths, so they have the same problem.
Possible fix: resolve relative frame paths against the project root (or the cwd) before calling Uri.file(). That keeps the fix from a6cf35b for inherited and trait methods and works for Pest's relative paths. A test with a relative details path such as tests/Feature/SomeTest.php would cover it.
Steps to reproduce
- Write a Pest test whose failure comes from an exception in application code:
it("fails", function () { Livewire::test(SomeComponent::class); // throws inside the component }); - Run it from the gutter or the Test Explorer.
- The test is marked as failed, but no message appears in the test file. Expected: the message at
tests/Feature/SomeTest.php:146, as in 3.9.40.
Extension settings
{
"phpunit.command": "docker compose exec -u sail -e XDEBUG_MODE=debug,coverage laravel.test",
"phpunit.phpunit": "vendor/bin/pest",
"phpunit.php": "php -dxdebug.start_with_request=1",
"phpunit.args": ["-c", "phpunit.xml", "--coverage-cobertura", "cobertura.xml"],
"phpunit.paths": { "${workspaceFolder}": "/var/www/html" }
}
Output channel log
##teamcity[testFailed name='it fails' message='...' details='at app/Livewire/SomeComponent.php:48|nat tests/Feature/SomeTest.php:146' flowId='...']
Environment
- OS: Windows with WSL2 (Linux)
- VS Code version: 1.145.0
- Extension version: 3.10.1 (works in 3.9.40)
- PHP version: 8.5.12
- PHPUnit / Pest version: PHPUnit 12.5.33 / Pest 4.7.8
- Run environment: Docker (Laravel Sail) via VS Code Remote - WSL
Project structure (if relevant)
project/
├── phpunit.xml
├── app/
└── tests/
├── Pest.php
├── TestCase.php
└── Feature/
└── SomeTest.php
- Dominant language
- TypeScript
- Stars
- 169
- Forks
- 72
- Avg merge
- 8m
- Merged PRs (30d)
- 184
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from recca0120/vscode-phpunit
-
bug
Difficulty 3/5 1-2 days Newbie friendliness 55/100
recca0120/vscode-phpunit#430 ·
Maintainers usually reply within 1 day
-
Suite header shows green "PASS" badge at start, never updates to "FAIL" when the whole file failsOpen
Difficulty 3/5 1-2 days Newbie friendliness 68/100
recca0120/vscode-phpunit#420 · 1 comment ·
Maintainers usually reply within 1 day
-
bug
Difficulty 4/5 3-5 days Newbie friendliness 48/100
recca0120/vscode-phpunit#417 · 1 comment · 2 reactions ·
Maintainers usually reply within 1 day
-
bug
Difficulty 3/5 1-2 days Newbie friendliness 62/100
recca0120/vscode-phpunit#416 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 4/5 3-5 days Newbie friendliness 45/100
recca0120/vscode-phpunit#415 · 2 comments ·
Maintainers usually reply within 1 day
All issues in recca0120/vscode-phpunit
Similar issues
-
[Bug]: A Markdown link with both a :line suffix and a #L fragment opens a path containing ":line"Open
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 1 day
-
status:needs-triage type:bug workstream:refimpl
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
GenAI-Security-Project/agent-control-standard#764 ·
Maintainers usually reply within 1 day
-
good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
TanbirRamim/vibereel#39 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
community first-timers-only good first issue hacktoberfest help wanted low hanging fruit up-for-grabs
Difficulty 1/5 Under an hour Newbie friendliness 72/100
lingdojo/kana-dojo#34988 · 1 comment · 5 reactions ·
Maintainers usually reply within 1 day