Advanced Composables, Plugins & Architecture
16 mins read
Free Lesson
Write fast, isolated unit tests, mock Pinia stores, and test emitted events and props.
Unit Testing Vue Components
import { mount } from '@vue/test-utils'
import { describe, it, expect } from 'vitest'
import CourseCard from './CourseCard.vue'
describe('CourseCard.vue', () => {
it('renders free badge when is_free prop is true', () => {
const wrapper = mount(CourseCard, {
props: { title: 'Complete Vue 3', isFree: true }
})
expect(wrapper.text()).toContain('Free Access')
})
})