Skip to content

Conversation

@JHWelch
Copy link

@JHWelch JHWelch commented Oct 8, 2025

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
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.

1 participant