Skip to content

Commit 2b635b1

Browse files
committed
fix: use screen whereever possible 🔥
1 parent 191f69e commit 2b635b1

4 files changed

Lines changed: 11 additions & 10 deletions

File tree

package-lock.json

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/__tests__/basic.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import "@testing-library/jest-dom/extend-expect";
22
import { createSignal, createEffect } from "solid-js";
3-
import { fireEvent, render } from "..";
3+
import { fireEvent, render, screen } from "..";
44

55
declare global {
66
var _$HYDRATION: Record<string, any>;
@@ -24,9 +24,9 @@ test("render calls createEffect immediately", () => {
2424
test("findByTestId returns the element", async () => {
2525
let ref!: HTMLDivElement;
2626

27-
const { findByTestId } = render(() => <div ref={ref} data-testid="foo" />);
27+
render(() => <div ref={ref} data-testid="foo" />);
2828

29-
expect(await findByTestId("foo")).toBe(ref);
29+
expect(await screen.findByTestId("foo")).toBe(ref);
3030
});
3131

3232
test("fireEvent triggers createEffect calls", () => {

src/__tests__/debug.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ afterEach(() => {
1313
test("debug pretty prints the container", () => {
1414
const HelloWorld = () => <h1>Hello World</h1>;
1515

16-
const { debug } = render(() => <HelloWorld />);
16+
render(() => <HelloWorld />);
1717

18-
debug();
18+
screen.debug();
1919

2020
expect(console.log).toHaveBeenCalledTimes(1);
2121
expect(console.log).toHaveBeenCalledWith(expect.stringContaining("Hello World"));
@@ -29,9 +29,9 @@ test("debug pretty prints multiple containers", () => {
2929
</>
3030
);
3131

32-
const { debug } = render(() => <HelloWorld />);
32+
render(() => <HelloWorld />);
3333
const multipleElements = screen.getAllByTestId("testId");
34-
debug(multipleElements);
34+
screen.debug(multipleElements);
3535
expect(console.log).toHaveBeenCalledTimes(2);
3636
expect(console.log).toHaveBeenCalledWith(expect.stringContaining("Hello World"));
3737
});

src/__tests__/stopwatch.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { createSignal, onCleanup } from "solid-js";
2-
import { fireEvent, render } from "..";
2+
import { fireEvent, screen, render } from "..";
33

44
function StopWatch() {
55
const [lapse, setLapse] = createSignal(0);
@@ -38,9 +38,9 @@ const wait = (time: number) => new Promise(resolve => setTimeout(resolve, time))
3838
test("unmounts a component", async () => {
3939
jest.spyOn(console, "error").mockImplementation(() => {});
4040

41-
const { unmount, getByText, container } = render(() => <StopWatch />);
41+
const { unmount, container } = render(() => <StopWatch />);
4242

43-
fireEvent.click(getByText("Start") as Element);
43+
fireEvent.click(screen.getByText("Start") as Element);
4444

4545
unmount();
4646

0 commit comments

Comments
 (0)