Async components — testing async behavior.
1import { describe, it, expect, vi } from "vitest"2import { mount } from "@vue/test-utils"3import AsyncComponent from "./AsyncComponent.vue"45describe("AsyncComponent", () => {6 it("loads data", async () => {7 // Mock async data8 vi.spyOn(global, "fetch").mockResolvedValue({9 json: () => Promise.resolve({ items: [1, 2, 3] })10 })1112 const wrapper = mount(AsyncComponent)1314 // Wait for data to load15 await wrapper.vm.$nextTick()1617 expect(wrapper.findAll("li")).toHaveLength(3)18 })19})