簡體   English   中英

Laravel 5.5和Vue.js刀片測試

[英]Laravel 5.5 & Vue.js Blade Testing

我的刀片中有以下內容......

<div>
  <contact-form></contact-form>
</div>

我想測試以確保Vue.js組件始終在我的測試中安裝...

public function testRoute()
{
    $this->visit('/');
    //stuck here
}

基本上我很期待測試刀片是否具有<contact-form> 我該怎么辦?

使用assertSee

斷言給定字符串包含在響應中

$this
    ->visit('/')
    ->assertSee('<contact-form>')
    ->assertSee('</contact-form>');

在這里查看更多laravel 5.5測試斷言

或者如果你想深入了解Laravel Dusk的客戶端瀏覽器測試,它有assertSourceHas方法。

您可以使用MakesHttpRequests.php trait中的callget方法來檢查文本:

// this returns \Illuminate\Foundation\Testing\TestResponse
$response = $this->get('/');
// use the TestResponse api
$response->assertSee($value);

Github源代碼參考: https//github.com/laravel/framework/blob/5.5/src/Illuminate/Foundation/Testing/Concerns/MakesHttpRequests.php

https://github.com/laravel/framework/blob/5.5/src/Illuminate/Foundation/Testing/TestResponse.php

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM