Why you should always assert your response codes when using assertSee in Laravel

I was writing my graduation project’s source code in TDD style, and noticed that my browser was displaying a big fat 500 error page, while my tests were still passing. After wondering why for a while, I decided to assert the response code, and voila, after asserting a status 200, my tests were not passing anymore.

The reason for this, is because the default debug page of Laravel contains a lot of the queries ran in your request. Because these queries contain the bound parameters, the page often ‘contains’ the strings that you are using assertSee on.

Thus; The strings are contained in the page’s contents, but are not visible in the way you’d expect them to.