testing-library / user-event

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

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

Open EgoziE opened 1 year ago

EgoziE commented 1 year 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 1 year 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 1 year ago

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