-
-
Notifications
You must be signed in to change notification settings - Fork 267
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Frontend Tests: Standardize userEvent
usage to conform with upstream recomendations
#5872
Frontend Tests: Standardize userEvent
usage to conform with upstream recomendations
#5872
Conversation
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
e0cc354
to
4fafc15
Compare
04d2f89
to
a4e15ee
Compare
It should be good now; I'm just waiting for tests to run. |
For details, see https://testing-library.com/docs/user-event/setup . Existing uses call `userEvent.setup()` internally in order to ease migration to v14. The compatibility call will most likely be removed in a future version. This also moves most tests to userEvent from fireEvent. Signed-off-by: Taylor Smock <tsmock@meta.com>
Signed-off-by: Taylor Smock <tsmock@meta.com>
a4e15ee
to
ac644e0
Compare
Sanity check: I'm getting randomly failing tests again. Can you reproduce that on your end? If so, I think we accidentally found the blocker for #5721. Note: I've found that the tests fail more reliably if the system is under load. |
Kudos, SonarCloud Quality Gate passed!
|
I have these 2 test cases failing on my end. FAIL src/views/tests/taskSelection.test.js (67.315 s)
● Task Selection Page › should change the button text to map selected task when user selects a task
thrown: "Exceeded timeout of 5000 ms for a test.
Use jest.setTimeout(newTimeout) to increase the timeout value, if this is a long-running test."
90 | });
91 |
> 92 | it('should change the button text to map selected task when user selects a task', async () => {
| ^
93 | act(() => {
94 | store.dispatch({
95 | type: 'SET_USER_DETAILS',
at src/views/tests/taskSelection.test.js:92:3
at Object.<anonymous> (src/views/tests/taskSelection.test.js:12:1)
● Task Selection Page › should change the button text to validate selected task
thrown: "Exceeded timeout of 5000 ms for a test.
Use jest.setTimeout(newTimeout) to increase the timeout value, if this is a long-running test."
150 | });
151 |
> 152 | it('should change the button text to validate selected task', async () => {
| ^
153 | act(() => {
154 | store.dispatch({
155 | type: 'SET_USER_DETAILS',
at src/views/tests/taskSelection.test.js:152:3
at Object.<anonymous> (src/views/tests/taskSelection.test.js:12:1) |
When I was troubleshooting #5721, I kept a log of what tests had failed. Both of the tests that you had fail failed for me (but not on a regular basis; out of 10 runs, they failed once). Test runs from #5721
|
Did all the test cases that failed in the log mention the same error message |
No; some of them were due to not finding a specified element within a specified amount of time (1s, IIRC, but I ended up testing with 5s). EDIT: The hard part is that sometimes I'll have a string of passing test runs, and then a failing test run with multiple test failures. It makes it a PITA to debug. |
Ran the test cases 5 times. I'm on Ubuntu with Node v16.
|
yeah it's been a strange scenario. And when only one file is examined, these scenarios would always pass. So strange. I ran tests on the |
Yes. Trying to debug the failures has been aggravating. Sometimes I'll change something, get a few runs in with no tests failing, think I've fixed the problem, then the next run fails. It doesn't help that my IDE doesn't have a "test until failure option". |
userEvent recommends using
userEvent.setup
instead ofuserEvent.click
(or other global methods).This also replaces most usages of
fireEvent
withuserEvent
equivalents.