user-event icon indicating copy to clipboard operation
user-event copied to clipboard

Clipboard - Check for window existence in `afterAll` functions

Open EgoziE opened this issue 2 years ago • 2 comments

What: Added a verification that window exists in functions resetClipboardStubOnView and detachClipboardStubFromView which are called on afterAll.

Why: When testing in SSR environment, window does (and should) not exist, therefore my tests fail.

How: Just added a conditional chaining.

Checklist:

  • [ ] Documentation
  • [ ] Tests
  • [x] Ready to be merged

I believe these functions should not be called in afterAll at all unless the user is actively using clipboard functionality. Thanks 💛

EgoziE avatar Nov 14 '23 10:11 EgoziE

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 34c29652d9fb9d1cfdd60669d8878a50c3d89148:

Sandbox Source
userEvent-dom Configuration
userEvent-react Configuration

codesandbox-ci[bot] avatar Nov 14 '23 10:11 codesandbox-ci[bot]

I didn't notice, it's almost a copy of https://github.com/testing-library/user-event/pull/1176 Please accept either PR 🙏🏼

EgoziE avatar Nov 14 '23 10:11 EgoziE

resolved by #1176

ph-fritsche avatar Feb 04 '25 22:02 ph-fritsche