Closed
Description
Issue
- Certain assertions for test cases in
useClipboard
don't consistently succeed. Previous failures: - The test file in question
Notes
- Inclined to believe that the issue is with the test, rather than the functionality, because while the test is new, the functionality has mostly been unchanged since it was first created over a year ago
- Testing clipboard functionality is weird in general, so depending on what's found after digging, it might be better to make some E2E tests instead
- Though obviously it'd be better to have a single test for the clipboard, rather than needing to have ad-hoc tests for everything that just happens to use the clipboard
- The main issue is that React Testing Library will inject a clipboard mock the moment you try to set up any kind of user session with
user.setup
. This is great most of the time, but the problem is that the clipboard always succeeds, and there's no way to remove the mock. Once there's a single setup, the entire test is basically "tainted" with false positives - Because the tests actually need to verify that the fallback functionality works when a clipboard isn't available on HTTP-only connection, we can't use
user.setup
at all