vitest

Vitest Error: No test found in suite <anonymous>


I using vitest for my testing environment, and after creating a new test, I'm getting the following error in my console:

Error: No test found in suite

I'm not sure what I'm doing wrong. Here's my test file:

import { emptyLinkGroupInfo } from "@/constants";
import { describe, expect, it, vi } from "vitest";
import LinkGroupModal from "./LinkGroupModal";
import { render } from '@testing-library/react';

describe(() => {
  it('renders LinkGroupModal for new group', () => {
    const { getByText, getAllByText } = render(<LinkGroupModal linkGroupInfo={emptyLinkGroupInfo} onClose={vi.fn()} isModalOpen={true} onFormSubmit={vi.fn()} onDeleteGroup={vi.fn()} />);
    
    expect(getByText("Add New Group")).toBeTruthy();
    expect(getByText("Group Name")).toBeTruthy();
    expect(getByText("Color")).toBeTruthy();
    expect(getAllByText("Link Name")).toHaveLength(4);
    expect(getAllByText("URL")).toHaveLength(4);
  })
})

I've searched StackOverflow but haven't found anything related to this error. How do I fix this?


Solution

  • You need to add a name to your describe() function, like so:

    describe("Test File", () => {
      // Your test code here
    })
    

    Without a name, Vitest can fail to recognize your test suite.