Search code examples
vue.jsbootstrap-vuevue-test-utils

How to select b-form-input component using vue test utils library?


How can I select b-form-input component according to its type such as email, password..

using vue-utils-library's find method?

in my login.html

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

my wrapper

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

in my test.spec file

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

but it returns

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

Solution

  • I suggest you should find your input like this:

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