LoginSignup
12
5

More than 3 years have passed since last update.

【Laravel】assertSeeとassertSeeTextの違い

Last updated at Posted at 2020-03-10

結論

assertSeeTextではHTMLタグをテストできません。


// HTMLタグ
$response->assertSee('<title>タイトル</title>'); // OK
$response->assertSeeText('<title>タイトル</title>'); // NG

// テキスト
$response->assertSee('タイトル'); // OK
$response->assertSeeText('タイトル'); // OK

彼らから見えている世界

assertSee


<li><a href="http://localhost">ホーム</a></li>\n
<li><a href="http://localhost/terms">利用規約</a></li>\n
<li><a href="http://localhost/tokutei">特定商取引法表示</a></li>\n
<li><a href="http://localhost/privacy">プライバシーポリシー</a></li>

assertSeeText


ホーム\n
利用規約\n
特定商取引法表示\n
プライバシーポリシー\n

余談

指定したビューが返されたことをテストする場合はassertViewIsを使いましょう。

12
5
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
12
5