pestphp/pest · error · ExpectationFailedException

Exception [$exception] not thrown.

Error message

Exception [$exception] not thrown.

What it means

Error "Exception [$exception] not thrown." thrown in pestphp/pest.

Source

Thrown at src/Mixins/Expectation.php:875

            if ($exceptionMessage !== null) {
                Assert::assertStringContainsString($exceptionMessage, $e->getMessage(), $message);
            }

            Assert::assertInstanceOf($exception, $e, $message);

            $callback($e);

            return $this;
        }

        Assert::assertTrue(true);

        if (! $exception instanceof Throwable && ! class_exists($exception)) {
            throw new ExpectationFailedException("Exception with message [$exception] not thrown.");
        }

        throw new ExpectationFailedException("Exception [$exception] not thrown.");
    }

    private function export(mixed $value): string
    {
        if (! $this->exporter instanceof Exporter) {
            $this->exporter = Exporter::default();
        }

        return $this->exporter->shortenedExport($value);
    }

    /**
     * @return self<TValue>
     */
    public function toBeUppercase(string $message = ''): self
    {
        Assert::assertTrue(ctype_upper((string) $this->value), $message);

View on GitHub (pinned to 1af74a215c)

When it happens

Trigger: Thrown at src/Mixins/Expectation.php:875 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of pestphp/pest@1af74a215c (2026-08-21). Data as JSON: /api/errors/37e7e5db510f6e28. Report an issue: GitHub.