Skip to content

Unable to check if spy has been called #21

@stevegreco

Description

@stevegreco

I have a pretty basic test that I have not been able to get to pass, it has worked fine with RTL, but as I migrate, these are the main things that are failing.

import { describe, it, expect, vi } from "vitest";
import { render } from "vitest-browser-react";
import { page } from "@vitest/browser/context";
import { Button } from "../Button";

 it.only("should fire the onPress/onClick handler", async () => {
    const handler = vi.fn();
    const screen = await page.render(<Button onClick={handler}>Button</Button>);
    await screen.getByRole("button").click();
    await expect(handler).toHaveBeenCalled();
  });
Image

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