-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: cypress/react18 rerender (#23360)
Co-authored-by: astone123 <adams@cypress.io>
- Loading branch information
Showing
10 changed files
with
523 additions
and
94 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
196 changes: 170 additions & 26 deletions
196
system-tests/__snapshots__/component_testing_spec.ts.js
Large diffs are not rendered by default.
Oops, something went wrong.
159 changes: 132 additions & 27 deletions
159
system-tests/__snapshots__/vite_dev_server_fresh_spec.ts.js
Large diffs are not rendered by default.
Oops, something went wrong.
210 changes: 175 additions & 35 deletions
210
system-tests/__snapshots__/webpack_dev_server_fresh_spec.ts.js
Large diffs are not rendered by default.
Oops, something went wrong.
27 changes: 27 additions & 0 deletions
27
system-tests/project-fixtures/react/src/Rerendering.cy.jsx
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,27 @@ | ||
import React from 'react'; | ||
|
||
function StatefulComponent ({ foo }) { | ||
const [bar, setBar] = React.useState(0); | ||
return ( | ||
<button | ||
onClick={() => { | ||
setBar(bar + 1); | ||
}} | ||
> | ||
{foo} {bar} | ||
</button> | ||
); | ||
}; | ||
|
||
describe('re-render', () => { | ||
it('maintains component state across re-renders', () => { | ||
cy.mount(<StatefulComponent foo="baz" />).then(({ rerender }) => { | ||
cy.get('button').should('have.text', 'baz 0'); | ||
cy.get('button').click().should('have.text', 'baz 1'); | ||
rerender(<StatefulComponent foo="baz" />) | ||
|
||
// The button should still show 1 after re-render | ||
cy.get('button').should('have.text', 'baz 1'); | ||
}); | ||
}); | ||
}); |
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,5 +1,11 @@ | ||
const {defineConfig} = require('vite') | ||
|
||
module.exports = defineConfig({ | ||
resolve: { | ||
alias: { | ||
'react': require.resolve('react'), | ||
'react-dom': require.resolve('react-dom'), | ||
}, | ||
}, | ||
logLevel: 'silent' | ||
}) |
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
8b8f20e
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:
8b8f20e
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 arm64
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:
8b8f20e
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 arm64
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:
8b8f20e
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:
8b8f20e
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
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: