Skip to content
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

Fix noob React Testing Library mistakes from #3007 #3031

Open
taneliang opened this issue Dec 7, 2020 · 4 comments
Open

Fix noob React Testing Library mistakes from #3007 #3031

taneliang opened this issue Dec 7, 2020 · 4 comments

Comments

@taneliang
Copy link
Member

I added React Testing Library in #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 #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 :)

@teikjun
Copy link
Contributor

teikjun commented Dec 9, 2020

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

  1. Run yarn test
  2. Repeat step 1 until you see the following error message (this takes at most 4 times in my experience)

image

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.

@teikjun
Copy link
Contributor

teikjun commented Dec 9, 2020

I can work on these issues! :)

@taneliang
Copy link
Member Author

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?

@taneliang
Copy link
Member Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants