Laravel 8 創(chuàng)建 Vue 斷言

2021-07-26 09:22 更新

Dusk 甚至還允許你對(duì) Vue 組件數(shù)據(jù)的狀態(tài)進(jìn)行斷言。比如:假設(shè)你的應(yīng)用有如下的 Vue 組件:

// HTML...

<profile dusk="profile-component"></profile>

//組件的定義

Vue.component('profile', {
    template: '<div>{{ user.name }}</div>',

    data: function () {
        return {
            user: {
                name: 'Taylor'
            }
        };
    }
}); 

你可以像這樣對(duì) Vue 組件狀態(tài)進(jìn)行斷言:

/**
 * Vue 基礎(chǔ)測(cè)試案例
 *
 * @return void
 */
public function testVue()
{
    $this->browse(function (Browser $browser) {
        $browser->visit('/')
                ->assertVue('user.name', 'Taylor', '@profile-component');
    });
} 


以上內(nèi)容是否對(duì)您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號(hào)
微信公眾號(hào)

編程獅公眾號(hào)