Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

how to test conditional rendering vue test utils

test('does not render an element', () => {
  const wrapper = mount(Component)

  // testing that an element is not rendered
  expect(wrapper.find('[data-test="tested-element"]').exists()).toBe(false)
  
  // testing that an element is rendered
  expect(wrapper.find('[data-test="tested-element"]').exists()).toBe(true)
})
Source by test-utils.vuejs.org #
 
PREVIOUS NEXT
Tagged: #test #conditional #rendering #vue #test #utils
ADD COMMENT
Topic
Name
2+7 =