Skip to content

Add support for AfterLastTestMethodErrored for use in Pest#336

Open
JHWelch wants to merge 2 commits into
nunomaduro:v8.xfrom
JHWelch:support-for-AfterLastTestMethodErrored
Open

Add support for AfterLastTestMethodErrored for use in Pest#336
JHWelch wants to merge 2 commits into
nunomaduro:v8.xfrom
JHWelch:support-for-AfterLastTestMethodErrored

Conversation

@JHWelch

@JHWelch JHWelch commented Oct 8, 2025

Copy link
Copy Markdown

I've been running into an error in Pest 4 that was reported a while back in 3.7.2 where AfterLastTestMethodErrored events are being passed into fromBeforeFirstTestMethodErrored.

Though the original issue was closed, if we look at Pest's source, it is simply ignoring a PHPStan error that this could happen.

} else {
    // @phpstan-ignore-next-line
    $state->add(TestResult::fromBeforeFirstTestMethodErrored($testResultEvent));
}

https://github.com/pestphp/pest/blob/08b09f2e98fc6830050c0237968b233768642d46/src/Support/StateGenerator.php#L34

To resolve this issue in Pest, Collision must support both kinds of test errors.

Because these errors seem like they can be handled in a common way, I created a single function that can receive both, but then kept the specific ones to not break backwards compatibility.

Pest could then take advantage of that single function to handle both cases and remove the PHPStan ignore

} else {
    $state->add(TestResult::fromTestErrorEvent($testResultEvent));
}

If this gets published I can follow up with the Pest PR in that repository.

@JHWelch JHWelch changed the title Add support for AfterLastTestMethodErrored Add support for AfterLastTestMethodErrored for use in Pest Oct 8, 2025
@mariosvasiliou

Copy link
Copy Markdown

I have the same issue using parallel, please @nunomaduro merge this pr

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