Skip to content

Commit 1bbd69c

Browse files
Linda Pengangelocordon
Linda Peng
authored andcommitted
Attempt to fix console warnings re: react testing library using await act(async () =>
1 parent a7c5c1d commit 1bbd69c

File tree

1 file changed

+36
-17
lines changed

1 file changed

+36
-17
lines changed

src/components/Auth/AuthForm.spec.js

Lines changed: 36 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -58,26 +58,40 @@ describe('Signup', () => {
5858
},
5959
});
6060

61-
fireEvent.change(getByLabelText(/username/i), {
62-
target: { value: 'Carolyne.Carter' },
63-
});
61+
await act(async () =>
62+
fireEvent.change(getByLabelText(/username/i), {
63+
target: { value: 'Carolyne.Carter' },
64+
})
65+
);
66+
67+
await act(async () =>
68+
fireEvent.change(getByLabelText(/password/i), {
69+
target: { value: 'password' },
70+
})
71+
);
72+
73+
await act(async () =>
74+
fireEvent.change(getByLabelText(/email/i), {
75+
target: { value: 'Carolyne.Carter@yahoo.com' },
76+
})
77+
);
78+
79+
await act(async () =>
80+
fireEvent.change(getByLabelText(/first name/i), {
81+
target: { value: 'Carolyne' },
82+
})
83+
);
84+
85+
await act(async () =>
86+
fireEvent.change(getByLabelText(/last name/i), {
87+
target: { value: 'Carter' },
88+
})
89+
);
6490

65-
fireEvent.change(getByLabelText(/password/i), {
66-
target: { value: 'password' },
67-
});
68-
fireEvent.change(getByLabelText(/email/i), {
69-
target: { value: 'Carolyne.Carter@yahoo.com' },
70-
});
71-
fireEvent.change(getByLabelText(/first name/i), {
72-
target: { value: 'Carolyne' },
73-
});
74-
fireEvent.change(getByLabelText(/last name/i), {
75-
target: { value: 'Carter' },
76-
});
7791
const submit = getByText('Sign Up');
78-
fireEvent.click(submit);
92+
await act(async () => fireEvent.click(submit));
7993

80-
await mockRegisterResponse();
94+
await act(async () => mockRegisterResponse());
8195

8296
expect(mockRegisterResponse).toHaveBeenCalledTimes(1);
8397
});
@@ -131,6 +145,11 @@ describe('Login', () => {
131145
},
132146
});
133147

148+
await act(async () =>
149+
fireEvent.change(getByLabelText(/username/i), {
150+
target: { value: 'Carolyne.Carter' },
151+
})
152+
);
134153
await act(async () =>
135154
fireEvent.change(getByLabelText(/username/i), {
136155
target: { value: 'Carolyne.Carter' },

0 commit comments

Comments
 (0)