1

When I try using wrapper.findComponent, I get the following error:

ErrorWrapper { selector: { ref: 'loginTab' } }

I have searched online but to no avail. Here is my test code:

describe('Sign-Up Test Cases', () => {
    const wrapper = mount(SignUp, {
        methods: {
            getProv: jest.fn()
        },
        localVue
    })
    
    it('Dialog contains a Login Input Field', () => {
        console.log(wrapper.findComponent({ ref: 'loginTab' }))
        expect(wrapper.findComponent({ ref: 'loginTab' }))
    })
})

localVue is already defined. Check the it statement where I am using the findComponent function.

UPDATE: Something else I tried.

I tried this and it didn't work.

import Vuetify, {VTab} from 'vuetify/lib'
// Some Code here
console.log(wrapper.findComponent(VTab))

and it didn't work. I got the following error:

ErrorWrapper {selector: [Function: VueComponent]}

1 Answer 1

-1

You have to import the component and use it as payload for the findComponent method:

const VTab = {
   template: '<div><slot></div>
}

const wrapper = shallowMount(SignUp, {
        global: {
           stubs: { VTab }
        },
    })

wrapper.findComponent(VTab)
Sign up to request clarification or add additional context in comments.

4 Comments

I tried this and it didn't work. import Vuetify, {VTab} from 'vuetify/lib' and console.log(wrapper.findComponent(VTab)) and it didn't work. I got the following error: ErrorWrapper {selector: [Function: VueComponent]}
If it's a component from vuetify, you have to stub the component. I change my answer
were you able to resolve this?
can you explain more your problem ?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.