[Vuejs]-How to test if a button is displayed in vue

0👍

Using async JS as we’ll wait for the components to be re-rendered by Vue.

it('should not allow sign in', async () =>{

await wrapper2.vm.$nextTick()
expect(wrapper2.find('#logout').hasStyle('display', 'none')).toBe(true)

https://vuejsdevelopers.com/2019/01/22/vue-what-is-next-tick/

Edit
.hasStyle has since been deprecated!

expect(wrapper.element.style.display).toBe('none');

https://github.com/vuejs/vue-test-utils/issues/330#issuecomment-356037493

Leave a comment