Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
JacobPotter opened this issue Nov 15, 2024 · 5 comments
Open

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

JacobPotter opened this issue Nov 15, 2024 · 5 comments

Comments

@JacobPotter
Copy link

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);
    });
});
@sheremet-va
Copy link
Member

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

@JacobPotter
Copy link
Author

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

@sheremet-va
Copy link
Member

sheremet-va commented Nov 15, 2024

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

@sheremet-va sheremet-va closed this as not planned Won't fix, can't repro, duplicate, stale Nov 15, 2024
@sheremet-va
Copy link
Member

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

@sheremet-va sheremet-va reopened this Nov 15, 2024
@JacobPotter
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants