diff --git a/src/Mixins/Expectation.php b/src/Mixins/Expectation.php index a6910b64..a9edcf07 100644 --- a/src/Mixins/Expectation.php +++ b/src/Mixins/Expectation.php @@ -844,6 +844,7 @@ final class Expectation $string = match (true) { is_string($this->value) => $this->value, + is_object($this->value) && method_exists($this->value, 'toSnapshot') => $this->value->toSnapshot(), is_object($this->value) && method_exists($this->value, '__toString') => $this->value->__toString(), is_object($this->value) && method_exists($this->value, 'toString') => $this->value->toString(), $this->value instanceof \Illuminate\Testing\TestResponse => $this->value->getContent(), // @phpstan-ignore-line diff --git a/tests/.pest/snapshots/Features/Expect/toMatchSnapshot/pass_with__toSnapshot_.snap b/tests/.pest/snapshots/Features/Expect/toMatchSnapshot/pass_with__toSnapshot_.snap new file mode 100644 index 00000000..afd4f5f9 --- /dev/null +++ b/tests/.pest/snapshots/Features/Expect/toMatchSnapshot/pass_with__toSnapshot_.snap @@ -0,0 +1,3 @@ +{ + "key": "