在vue中註冊用於cypress元件測試的全域自訂指令
P粉529581199
P粉529581199 2024-03-26 22:44:23
0
1
410

有沒有辦法在 vue.js 中註冊用於 cypress 元件測試的全域自訂指令。只要註冊

app.directive('some',(el,binding)=>{{...})

main.js 檔案中無法解決問題。因為在元件測試元件中未能解析該指令。

像這樣的本機暫存器:

mount(SomeComp,{
directive:{
  'some': {...}
})

不是一個好的選擇。因為我在每個元件中都使用這​​個指令,並且需要在每個元件中本地註冊。

我如何註冊用於賽普拉斯元件測試的全域指令?

謝謝

P粉529581199
P粉529581199

全部回覆(1)
P粉884667022

創造你自己的坐騎,

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)
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!