'Is there a way of formatting failed output from Laravel's assertSee() test?

Laravel has several built-in assertions that allow you to query the Response from a Request.

    public function testWebpage()
    {
        $response = $this->get('/important-page')
            ->assertStatus(200)
            ->assertViewIs('page')
            ->assertSee('This is a page')
            ->assertSee('login');
    }

This is great, except when assertSee fails, it dumps a standard PHPUnit error--something like...

1) Tests\PageTest::testWebpage
Failed asserting that '<!DOCTYPE html>\n
<!--[if IE 8]><html class="ie8" lang=""><![endif]-->\n
<!--[if IE 9]><html class="ie9" lang=""><![endif]-->\n
<html lang="en">\n
<!--<![endif]-->\n
<!-- start: HEAD -->\n
<head>\n
...

[Insert 500 lines of HTML here]
...

</body>\n
</html>\n
' contains "This is a page".

Is there a sensible solution to outputting the failed text so that it's useful? Can I specify a rough context (maybe a div#welcome) to diff rather than an entire file? Can I optionally output to a file to inspect outside of my console? Can I get some sort of collapsible output? Can I catch the PHPUnit failed assertion and trims output to 20 lines?

It not only ruins the ease of debugging this one test--it makes it difficult to locate other failures if there's another 20 errors that are also generated by assertSee().



Solution 1:[1]

I wondered the same thing, but the only thing I found was to output to a file.

The syntax is:

--log-junit file.txt

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Stefan Pavlov