testing-library / user-event

🐕 Simulate user events
https://testing-library.com/user-event
MIT License
2.14k stars 242 forks source link

Clipboard - Check for window existence in `afterAll` functions #1178

Open EgoziE opened 7 months ago

EgoziE commented 7 months ago

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:

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

codesandbox-ci[bot] commented 7 months ago

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
EgoziE commented 7 months ago

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