diff --git a/src/Context/JsonContext.php b/src/Context/JsonContext.php index 91ba055e..704ef97a 100644 --- a/src/Context/JsonContext.php +++ b/src/Context/JsonContext.php @@ -226,7 +226,13 @@ public function theJsonNodeShouldContain($node, $text): void $actual = $this->inspector->evaluate($json, $node); - $this->assertContains($text, (string) $actual); + $printedActual = \strlen($actual) > 50 ? substr($actual, 0, 50).'[…]' : $actual; + + $this->assertContains( + $text, + (string) $actual, + 'The node "'.$node.'" does not contain the expected text "'.$text.'" (found "'.$printedActual.'")' + ); } /** @@ -252,7 +258,13 @@ public function theJsonNodeShouldNotContain($node, $text): void $actual = $this->inspector->evaluate($json, $node); - $this->assertNotContains($text, (string) $actual); + $printedActual = \strlen($actual) > 50 ? substr($actual, 0, 50).'[…]' : $actual; + + $this->assertNotContains( + $text, + (string) $actual, + 'The node "'.$node.'" does contain "'.$text.'" while it should not (found "'.$printedActual.'")' + ); } /**