Skip to content

Vitest UI Browser mode, not all test previews are available #6

@JacobPotter

Description

@JacobPotter

When using Vitest UI with Browser mode, and using test suites, unable to preview individual tests in Browser UI:
image

Example code:

import {describe, expect, it} from "vitest";
import Line from "./Line";
import {render} from "vitest-browser-react";
import {FC} from "react";

describe('Line', () => {
    it('renders without error', () => {
        const {container} = render(
            <Line
                x0={0}
                y0={0}
                x1={10}
                y1={10}
            />
        );

        expect(container.firstChild).toBeDefined();
    });

    it('renders with className', () => {
        const {container} = render(
            <Line
                x0={0}
                y0={0}
                x1={10}
                y1={10}
                className='test-class'
            />
        );

        expect(container.querySelector('.test-class')).toBeDefined();
    });

    it('renders within given class', () => {
        const Wrapper: FC = () => <div className="within-class"></div>;

        const { container } = render(
          <Line x0={0} y0={0} x1={10} y1={10} within="within-class" />,
          { wrapper: Wrapper },
        );

        const wrapperElement = container.parentElement;
        expect(wrapperElement).toContainElement(container.firstChild);
    });
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions