繁体   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