nusmods
nusmods copied to clipboard
Fix noob React Testing Library mistakes from #3007
I added React Testing Library in https://github.com/nusmodifications/nusmods/pull/3007, but as it was the first time I used it I made some common mistakes 😅
I only found out about them when working on https://github.com/nusmodifications/nusmods/pull/3009, after which I added some commits that fix the mistakes made within the PR. However, to avoid ballooning it, I did not fix mistakes made in #3007.
It's time to fix them :)
I think there's a flaky test in TimetableContainer.test.tsx. It may be related to this issue, but I haven't figured out how to fix it yet 😅
The error highlights the following line:
expect(await screen.findByRole('button', { name: 'Import' })).toBeInTheDocument();
Steps to reproduce
- Run
yarn test - Repeat step 1 until you see the following error message (this takes at most 4 times in my experience)

Additional Information
If we run with yarn test -i or run yarn test TimetableContainer, there is no error. This probably means that some other test is affecting this one.
I can work on these issues! :)
Interesting! I'm unable to reproduce this on my computer despite running yarn test 10 times. Not sure what you're using, but maybe it's more easily reproducible on slower computers? Or maybe this is caused by a network call we forgot to mock?
I can work on these issues! :)
Oops, missed this. Thank you! :D Feel free to split off that flaky test into its own issue, especially if it requires a significant amount of work/code to fix.