Skip to content
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

chore: update react in the reporter from 17.0.2 to 18.3.1 #30567

Merged
merged 1 commit into from
Nov 14, 2024

Conversation

AtofStryker
Copy link
Contributor

@AtofStryker AtofStryker commented Nov 6, 2024

Additional details

Updates the Cypress Reporter from React 17.0.2 to 18.3.1. This PR does the minimum work to get the Cypress reporter on React 18.3.1, which just means updating the render methods. Other deprecations and issues are scoped to #30574.

Steps to test

How has the user experience changed?

PR Tasks

@AtofStryker AtofStryker changed the title chore: update to react 18 for the reporter from 17.0.2 to 18.3.1 chore: update to react for the reporter from 17.0.2 to 18.3.1 Nov 6, 2024
Copy link

cypress bot commented Nov 7, 2024

cypress    Run #58225

Run Properties:  status check passed Passed #58225  •  git commit 7a18bb25b8: chore: update to react 18 for the reporter from 17.0.2 to 18.3.1 [run ci]
Project cypress
Branch Review chore/update_react_18
Run status status check passed Passed #58225
Run duration 22m 15s
Commit git commit 7a18bb25b8: chore: update to react 18 for the reporter from 17.0.2 to 18.3.1 [run ci]
Committer AtofStryker
View all properties for this run ↗︎

Test results
Tests that failed  Failures 0
Tests that were flaky  Flaky 6
Tests that did not run due to a developer annotating a test with .skip  Pending 1327
Tests that did not run due to a failure in a mocha hook  Skipped 0
Tests that passed  Passing 29332
View all changes introduced in this branch ↗︎
UI Coverage  46.67%
  Untested elements 187  
  Tested elements 168  
Accessibility  92.56%
  Failed rules  3 critical   8 serious   2 moderate   2 minor
  Failed elements 895  

@AtofStryker AtofStryker linked an issue Nov 7, 2024 that may be closed by this pull request
@@ -11,12 +11,6 @@ export function setInitializedReporter (val: boolean) {
hasInitializeReporter = val
}

async function unmountReporter () {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this isn't used anywhere. Figured a good time to delete dead code as to unmount in react 18 we would need a root reference and I would rather avoid the complexity

@@ -56,11 +50,12 @@ function renderReporter (
testFilter: specsStore.testFilter,
})

window.UnifiedRunner.ReactDOM.render(reporter, root)
const reactDomRoot = window.UnifiedRunner.ReactDOM.createRoot(root)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


const currentTestLog = findReactInstance(cy.$$('.runnable-active', top?.document)[0])

currentTestLog.props.model._isOpen = true
Copy link
Contributor Author

@AtofStryker AtofStryker Nov 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this no longer works (hence why we are waiting the LONG_RUNNING_THRESHOLD above).

The model does get updated in <Attempt/>, but the prop passed into <Collapsible/> in componentDidUpdate still says false, which seems like a bug.

Normally I would file an issue for this, but I would argue that waiting the full 2 seconds for the attempt to open is a better test since this is what the user would exactly experience and better tests our code, even though it adds a few seconds to each test leveraging this. We don't do this is many tests (maybe 7 tests total) so it seems fine.

@@ -154,8 +154,10 @@ declare global {
if (window.Cypress) {
window.state = appState
window.render = (props) => {
// @ts-ignore
render(<Reporter {...props as Required<BaseReporterProps>} />, document.getElementById('app'))
const container: HTMLElement = document.getElementById('app') as HTMLElement
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// Since updating the Reporter to React 18, this is no longer the case. The element looks to be rerendered
// and the previous reference detached. We will need to come up with a different way to test this.
// @see https://github.com/cypress-io/cypress/issues/30526.
ensureCorrectHighlightPositions('#button', true)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

comment says it all 😅

@@ -53,6 +52,7 @@ export function mount (jsx: React.ReactNode, options: MountOptions = {}, rerende
// to wipe away any state
cleanup()
const internalOptions: InternalMountOptions = {
// @ts-expect-error
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this has to do with a type mismatch now that exists in the root of the monorepo 🥴 . This will be addressed with #29607

@AtofStryker AtofStryker self-assigned this Nov 7, 2024
@@ -94,6 +94,7 @@
"@octokit/auth-app": "6.0.3",
"@octokit/core": "5.0.2",
"@percy/cli": "1.27.4",
"@reach/dialog": "0.10.5",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for whatever reason this package is no longer getting hoisted. So when the runner tries to build the reporter, the package is missing. This puts it in the root of the repo so its available in both places as opposed to installing it in 2 places

@AtofStryker AtofStryker marked this pull request as ready for review November 7, 2024 14:24
@ryanthemanuel ryanthemanuel changed the title chore: update to react for the reporter from 17.0.2 to 18.3.1 chore: update react in the reporter from 17.0.2 to 18.3.1 Nov 7, 2024
@AtofStryker AtofStryker added pkg/reporter This is due to an issue in the packages/reporter directory Cypress 14 Issues scoped for Cypress 14 labels Nov 7, 2024
@AtofStryker AtofStryker merged commit a6d2b2f into release/14.0.0 Nov 14, 2024
84 of 86 checks passed
@AtofStryker AtofStryker deleted the chore/update_react_18 branch November 14, 2024 00:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Cypress 14 Issues scoped for Cypress 14 pkg/reporter This is due to an issue in the packages/reporter directory
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update @packages/reporter from React 17.0.2 to 18.3.1
2 participants