Skip to content

[5.4] Add assertSeeText() and assertDontSeeText() to TestResponse#18690

Merged
taylorotwell merged 2 commits intolaravel:5.4from
stidges:5.4-response-assertions
Apr 6, 2017
Merged

[5.4] Add assertSeeText() and assertDontSeeText() to TestResponse#18690
taylorotwell merged 2 commits intolaravel:5.4from
stidges:5.4-response-assertions

Conversation

@stidges
Copy link
Copy Markdown
Contributor

@stidges stidges commented Apr 6, 2017

This pull request adds two new assertions to the TestResponse class: assertSeeText() and assertDontSeeText().

Motivation

These assertions are really helpful when asserting against HTML responses, as visual design of the page shouldn't make a test pass or fail. Given the following HTML:

<strong>Views:</strong> 2

I would currently test this using the following assertion:

$response->assertSee('<strong>Views:</strong> 2');

But whenever a designer thinks it would look better if it was also italic, or add some extra CSS classes, my test would break. All I really care about is that the views are shown on the page. The assertSeeText() assertion solves this issue:

$response->assertSeeText('Views: 2');

@taylorotwell taylorotwell merged commit acc5feb into laravel:5.4 Apr 6, 2017
@stidges stidges deleted the 5.4-response-assertions branch April 6, 2017 15:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants