Skip to content

Commit

Permalink
feat: support react 19 for component testing with cypress/react [run ci]
Browse files Browse the repository at this point in the history
  • Loading branch information
AtofStryker committed Nov 19, 2024
1 parent 37ea320 commit f6b67a2
Show file tree
Hide file tree
Showing 11 changed files with 2,899 additions and 10 deletions.
4 changes: 4 additions & 0 deletions cli/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ _Released 12/3/2024 (PENDING)_
- The `resourceType` option on `cy.intercept` has been deprecated. We anticipate the resource types to change or be completely removed in the future. Our intention is to replace essential functionality dependent on the `resourceType` within Cypress in a future version (like hiding network logs that are not fetch/xhr). Please leave feedback on any essential uses of `resourceType`
in this [GitHub issue](https://github.com/cypress-io/cypress/issues/30447). Addresses [#30433](https://github.com/cypress-io/cypress/issues/30433).

**Features:**

- Cypress Component Testing now supports `React` version 19. Cypress will allow detected use of the React 19 Release Candidate until React 19 is officially released. Addresses [#29470](https://github.com/cypress-io/cypress/issues/29470).

**Bugfixes:**

- Elements with `display: contents` will no longer use box model calculations for visibility, and correctly show as visible when it is visible. Fixed in [#29680](https://github.com/cypress-io/cypress/pull/29680). Fixes [#29605](https://github.com/cypress-io/cypress/issues/29605).
Expand Down
8 changes: 4 additions & 4 deletions npm/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@
"vite-plugin-require-transform": "1.0.12"
},
"peerDependencies": {
"@types/react": "^18",
"@types/react-dom": "^18",
"@types/react": "^18 || ^19",
"@types/react-dom": "^18 || ^19",
"cypress": "*",
"react": "^18",
"react-dom": "^18"
"react": "^18 || ^19",
"react-dom": "^18 || ^19"
},
"files": [
"dist"
Expand Down
3 changes: 1 addition & 2 deletions packages/app/cypress/e2e/runner/ct-framework-errors.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@ function loadErrorSpec (options: Options): VerifyFunc {
return createVerify({ fileName: Cypress._.last(filePath.split('/')), hasPreferredIde: false, mode: 'component' })
}

// keeping structure as to easily adapt for future versions of react
const reactVersions = [18] as const
const reactVersions = [18, 19] as const

reactVersions.forEach((reactVersion) => {
describe(`React ${reactVersion}`, {
Expand Down
4 changes: 2 additions & 2 deletions packages/scaffold-config/src/dependencies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export const WIZARD_DEPENDENCY_REACT = {
package: 'react',
installer: 'react',
description: 'A JavaScript library for building user interfaces',
minVersion: '^18.0.0',
minVersion: '^18.0.0 || ^19.0.0-rc || ^19.0.0',
} as const

export const WIZARD_DEPENDENCY_REACT_DOM = {
Expand All @@ -31,7 +31,7 @@ export const WIZARD_DEPENDENCY_REACT_DOM = {
package: 'react-dom',
installer: 'react-dom',
description: 'This package serves as the entry point to the DOM and server renderers for React',
minVersion: '^18.0.0',
minVersion: '^18.0.0 || ^19.0.0-rc || ^19.0.0',
} as const

export const WIZARD_DEPENDENCY_TYPESCRIPT = {
Expand Down
296 changes: 296 additions & 0 deletions system-tests/__snapshots__/component_testing_spec.ts.js

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.sample-bg {
background: rgb(255, 0, 0);
}
5 changes: 5 additions & 0 deletions system-tests/projects/react19/cypress/support/component.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { mount } from 'cypress/react'

import './backgroundColor.css'

Cypress.Commands.add('mount', mount)
19 changes: 19 additions & 0 deletions system-tests/projects/react19/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"name": "react19",
"version": "0.0.0-test",
"dependencies": {
"react": "19.0.0-rc.1",
"react-dom": "19.0.0-rc.1"
},
"devDependencies": {
"@vitejs/plugin-react": "^4.3.3",
"babel-loader": "^9.2.1",
"css-loader": "^7.1.2",
"style-loader": "^4.0.0",
"vite": "^5.4.10",
"webpack": "^5.96.1",
"webpack-dev-server": "^5.1.0"
},
"sideEffects": false,
"projectFixtureDirectory": "react"
}
7 changes: 7 additions & 0 deletions system-tests/projects/react19/vite.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'

// https://vitejs.dev/config/
export default defineConfig({
plugins: [react()],
})
2,557 changes: 2,557 additions & 0 deletions system-tests/projects/react19/yarn.lock

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions system-tests/test/component_testing_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ describe('component testing projects', function () {
})
})

// keeping structure as to adapt to future versions of react
const REACT_MAJOR_VERSIONS = ['18'] as const
const REACT_MAJOR_VERSIONS = ['18', '19'] as const

describe(`React major versions with Vite`, function () {
systemTests.setup()
Expand Down

0 comments on commit f6b67a2

Please sign in to comment.