Unit — individual functions. Integration — component interaction.
Unit test:
1import { describe, it, expect } from "vitest"2import { useCounter } from "./useCounter"34describe("useCounter", () => {5 it("increments", () => {6 const { count, increment } = useCounter()7 increment()8 expect(count.value).toBe(1)9 })10})
Integration test:
1import { describe, it, expect } from "vitest"2import { mount } from "@vue/test-utils"3import App from "./App.vue"45describe("App", () => {6 it("renders correctly", () => {7 const wrapper = mount(App)8 expect(wrapper.find("h1").text()).toBe("Hello")9 })10})
Key differences: