-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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(component-testing): Correctly unmount react components #15250
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,9 +26,11 @@ export function init (importPromises, parent = (window.opener || window.parent)) | |
Cypress.onSpecWindow(window, importPromises) | ||
Cypress.action('app:window:before:load', window) | ||
|
||
beforeEach(() => { | ||
// This really have no sense for @cypress/react and @cypress/vue | ||
// It is anyway required to mount a new | ||
// Before all tests we are mounting the root element, **not beforeEach** | ||
// Cleaning up platform between tests is the responsibility of the specific adapter | ||
// because unmounting react/vue component should be done using specific framework API | ||
// (for devtools and to get rid of global event listeners from previous tests.) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The comment is a little confusing to me - Just for my understanding, unmounting the component won't actually get rid of the global listener (REACT_DEVTOOLS_GLOBAL_HOOK) though, right? It will just make sure the component is no longer present in the devtools. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I mean if you are doing There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Right, sure. Makes sense. One thing we might need to be careful is if the devtools do |
||
before(() => { | ||
appendTargetIfNotExists('__cy_root') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We probably need to fix vue with using this root too. Right now, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I did change this so it is matching the old react behavior (that I deleted here) – but yes, I do want to test this in scope of devtools PR |
||
}) | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Though this is not part of the fix, this clean-up is a very good idea.
I am going to check for the same issues in the vue side.