nunomaduro / laravel-mojito

🍹 A lightweight package for testing Laravel views in isolation
http://nunomaduro.com/
MIT License
373 stars 16 forks source link

assertions are wrong because of wrong html output #3

Closed Zae closed 4 years ago

Zae commented 4 years ago

Hi,

It seems that DomCrawler changes my HTML which makes my tests fail.

Lets say the output from my view is:

WIDGETBEFBEFOREArchivesAFTER
<ul></ul>
WIDGETAFT

And I test like this:

static::assertView('view)
            ->contains('BEFORE')
            ->contains('AFTER')
            ->contains('WIDGETBEF');
            ->contains('WIDGETAFT');

This fails because mojito thinks the output of the view is:

<p>WIDGETBEFBEFOREArchivesAFTER</p>

This is definitely not the output of the view, but this is probably what DomCrawler makes of it when it imports the HTML.

nunomaduro commented 4 years ago

Can you try to debug this to track this specific line of this problem ?

Zae commented 4 years ago

Hi Nuno,

I've added a testcase in my PR, you can see the failure in travis.