vitest-dev/vitest-browser-react

Vitest UI Browser mode, not all test previews are available

Opened this issue · 5 comments

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);
    });
});

Not sure what you mean. The UI only shows the last running test, Vitest doesn't implement preview of different tests

That is what I mean. the preview from the last running test does not show if that test is part of a suite, in fact, I cannot run subtests in a suite from ui either

image

The play button on subtests are disabled. I do have includeTaskLocation set to true as well per docs

in fact, I cannot run subtests in a suite from ui either

This has nothing to do with this package; this is how Vitest UI works at the moment. There is an open PR that implements this: vitest-dev/vitest#6641

the preview from the last running test does not show if that test is part of a suite

This is interesting though, need to confirm first before closing

Good to know, will watch the other PR for that. Let me know what you find on the second part though.