有沒有辦法在 vue.js 中注冊用于 cypress 組件測驗的全域自定義指令。只需注冊
app.directive('some',(el,binding)=>{{...})
在 main.js 檔案中無法解決問題。因為在組件測驗組件失敗時決議該指令。
像這樣的本地暫存器:
mount(SomeComp,{
directive:{
'some': {...}
})
不是好的選擇。因為我在每個組件中都使用這個指令并且需要在每個組件中進行本地注冊。
我如何注冊柏樹組件測驗的全域指令?
謝謝
uj5u.com熱心網友回復:
創建自己的坐騎,
import { mount } from '@cypress/vue'
export const mountWithDirective = (myComponent) => {
return mount(myComponent, {
directive:{
'some': {...}
})
}
將其放入 /cypress/support/index.js 或您選擇的其他檔案中。
// test
import { mountWithDirective } from 'cypress/support'
import Component from './Component.vue'
it...
mountWithDirective(Component)
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/434128.html
標籤:javascript Vue.js 测试 柏 柏树组件测试运行器
下一篇:無法使用賽普拉斯加載特定URL
