Skip to content

Commit e7e888a

Browse files
committed
test: remove @testing-library/react-hooks
testing-library/react-testing-library#991
1 parent 3a8f8f8 commit e7e888a

File tree

5 files changed

+239
-230
lines changed

5 files changed

+239
-230
lines changed

package.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,7 @@
4040
"react": ">=16.8.2"
4141
},
4242
"devDependencies": {
43-
"@testing-library/react": "^13.2.0",
44-
"@testing-library/react-hooks": "^8.0.0",
43+
"@testing-library/react": "^14.0.0",
4544
"@types/jest": "^27.4.0",
4645
"@types/react": "^18.0.9",
4746
"@types/react-dom": "^18.0.3",

tests/useRequest.test.ts

+18-16
Original file line numberDiff line numberDiff line change
@@ -71,43 +71,44 @@ describe("useRequest", () => {
7171
useRequest(() => ({ url: "/users", method: "GET" })),
7272
);
7373

74-
void act(() => {
75-
void result.current[0]().ready();
74+
act(() => {
75+
result.current[0]()
76+
.ready()
77+
.catch(() => undefined);
7678
expect(result.current[1].hasPending).toBeFalsy();
7779
});
7880

7981
unmount();
8082
expect(result.current[1].hasPending).toBeTruthy();
8183
});
8284

83-
it("clear", async () => {
84-
const { result, unmount, waitForNextUpdate } = renderHook(() =>
85+
it("clear", () => {
86+
const { result, unmount } = renderHook(() =>
8587
useRequest(() => ({ url: "/users", method: "GET" })),
8688
);
8789

88-
void act(() => {
89-
void result.current[0]()
90+
act(() => {
91+
result.current[0]()
9092
.ready()
9193
.catch((e) => {
9294
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
9395
expect(e.message).toStrictEqual("clear-messgae");
9496
});
9597
});
9698

97-
void act(() => {
98-
void result.current[0]()
99+
act(() => {
100+
result.current[0]()
99101
.ready()
100102
.then((r) => {
101103
expect(r[0]).toStrictEqual(okResponse);
102-
});
104+
})
105+
.catch(() => undefined);
103106

104107
result.current[1].clear("clear-messgae");
105108
});
106109

107-
await waitForNextUpdate();
108-
109-
void act(() => {
110-
void result.current[0]()
110+
act(() => {
111+
result.current[0]()
111112
.ready()
112113
.catch((e) => {
113114
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
@@ -117,12 +118,13 @@ describe("useRequest", () => {
117118

118119
unmount();
119120

120-
void act(() => {
121-
void result.current[0]()
121+
act(() => {
122+
result.current[0]()
122123
.ready()
123124
.then((r) => {
124125
expect(r[0]).toStrictEqual(okResponse);
125-
});
126+
})
127+
.catch(() => undefined);
126128

127129
result.current[1].clear("unmount-messgae");
128130
});

0 commit comments

Comments
 (0)