SolidJSS
SolidJS3y ago
10 replies
oneiro

Solid-testing library TS-eslint-errors

Hey<

I am just starting out using solids testing library and setup my project according to this example: https://github.com/solidjs/solid-start/tree/main/examples/with-vitest/src

However I am getting some TS-errors I am not quite sure how to resolve correctly.

My Counter.test.tsx looks exactly like in the example:

import { fireEvent, render } from "@solidjs/testing-library";
import Counter from "./Counter";

describe("<Counter />", () => {
  it("increments value", async () => {
    const { queryByRole, unmount } = render(() => <Counter />);
    const button = (await queryByRole("button")) as HTMLButtonElement;
    expect(button).toBeInTheDocument();
    expect(button).toHaveTextContent(/Clicks: 0/);
    fireEvent.click(button);
    expect(button).toHaveTextContent(/Clicks: 1/);
    unmount();
  });

  it("renders 1", () => {
    const { container, unmount } = render(() => <Counter />);
    expect(container).toMatchSnapshot();
    unmount();
  });
});


However on the destructor of queryByRole I receive the following error:

Avoid referencing unbound methods which may cause unintentional scoping of `this`.
If your function does not access `this`, you can annotate it with `this: void`, or consider using an arrow function instead. [@typescript-eslint/unbound-method]


Furhtermore on the call to queryByRole I receive an error, that queryByRole does not return a Promise and is therefore not awaitable.

Is this an error on my part or is this an error already present inside the example repo?

Thanks in advance
GitHub
SolidStart, the Solid app framework. Contribute to solidjs/solid-start development by creating an account on GitHub.
solid-start/examples/with-vitest/src at main · solidjs/solid-start
Was this page helpful?