-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(@cypress/react): Devtools unpredictable resets (#15612)
* fix: Devtools unpredictable resets * Remove cleaning up from webpack-dev-server * Fix lint errors * Get back observer * fix: bring back cleanup (#15634) * fix: wait for fw teardown to do html teardown * fix: port responsibility of teardown to frameworks * chore: add comments * fix: typings * fix: react unmount cannot be called in the right hook * run dtslint Co-authored-by: Barthélémy Ledoux <[email protected]> Co-authored-by: ElevateBart <[email protected]>
- Loading branch information
1 parent
d9c3ae2
commit b1f831a
Showing
24 changed files
with
182 additions
and
173 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,5 +7,6 @@ | |
<title>Components App</title> | ||
</head> | ||
<body> | ||
<div id="__cy_root"></div> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,12 @@ | ||
/* eslint-disable no-console */ | ||
/*eslint-env browser */ | ||
|
||
function appendTargetIfNotExists (id: string, tag = 'div', parent = document.body) { | ||
let node = document.getElementById(id) | ||
|
||
node = document.createElement(tag) | ||
node.setAttribute('id', id) | ||
parent.appendChild(node) | ||
|
||
return node | ||
} | ||
|
||
export function init (importPromises, parent = (window.opener || window.parent)) { | ||
const Cypress = (window as any).Cypress = parent.Cypress | ||
export function init (importPromises, parent: Window = (window.opener || window.parent)) { | ||
const Cypress = window.Cypress = parent.Cypress | ||
|
||
if (!Cypress) { | ||
throw new Error('Tests cannot run without a reference to Cypress!') | ||
} | ||
|
||
Cypress.onSpecWindow(window, importPromises) | ||
Cypress.action('app:window:before:load', window) | ||
|
||
// In this variable, we save head | ||
// innerHTML to account for loader installed styles | ||
let headInnerHTML = '' | ||
|
||
// before the run starts save | ||
Cypress.on('run:start', () => { | ||
headInnerHTML = document.head.innerHTML | ||
}) | ||
|
||
// 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.) | ||
Cypress.on('test:before:run', () => { | ||
document.body.innerHTML = '' | ||
document.head.innerHTML = headInnerHTML | ||
appendTargetIfNotExists('__cy_root') | ||
}) | ||
|
||
return { | ||
restartRunner: Cypress.restartRunner, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/** | ||
* We need this file to call window.Cypress | ||
*/ | ||
export declare global { | ||
interface Window { | ||
Cypress: Cypress.Cypress; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
b1f831a
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.
Circle has built the
linux x64
version of the Test Runner.Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.
Run this command to install the pre-release locally:
b1f831a
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.
AppVeyor has built the
win32 ia32
version of the Test Runner.Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.
Run this command to install the pre-release locally:
b1f831a
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.
AppVeyor has built the
win32 x64
version of the Test Runner.Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.
Run this command to install the pre-release locally:
b1f831a
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.
Circle has built the
darwin x64
version of the Test Runner.Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.
Run this command to install the pre-release locally: