【问题标题】:How to select b-form-input component using vue test utils library?如何使用 vue test utils 库选择 b-form-input 组件?
【发布时间】:2020-04-19 12:06:17
【问题描述】:

如何根据电子邮件、密码等类型选择 b-form-input 组件..

使用 vue-utils-library 的 find 方法?

在我的 login.html 中

<b-form-input
  id="email"
  type="email"
  v-model="credentials.email"
  :class="{ 'is-invalid': submitted && $v.credentials.email.$error }" />

我的包装

wrapper = mount(Login,
      {
        localVue,
        store,
        mocks: {
          $route: {},
          $router: {
            push: jest.fn()
          }
        }
      })

在我的 test.spec 文件中

it ('select', () => {
    const d = wrapper.find('BFormInput[type="email"]')
    console.log(d)
  })

但它会返回

ErrorWrapper { selector: 'BFormInput[type="email"]' }

【问题讨论】:

    标签: vue.js bootstrap-vue vue-test-utils


    【解决方案1】:

    我建议你应该像这样找到你的输入:

    const d = wrapper.find('input.form-control[type="email"]')
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-05-26
      • 2019-05-13
      • 2019-07-16
      • 2021-02-17
      • 2020-12-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多