Skip to content

Commit 0c661b4

Browse files
authored
breaking: remove support for React 16 and 17 for Cypress Component Testing. Additionally, remove the cypress/react18 testing harness and merge it upstream with cypress/react (#30590)
* breaking: remove support for react 16 and 17 for component testing and move cypress/react18 upstream into cypress/react [run ci] * update tests / suggestions from code review [run ci]
1 parent 53b24b1 commit 0c661b4

File tree

92 files changed

+618
-2051
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

92 files changed

+618
-2051
lines changed

.circleci/cache-version.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# Bump this version to force CI to re-create the cache from scratch.
22

3-
11-07-24-vue-cli-service-removal
3+
11-07-24-react-16-17-removal

.circleci/workflows.yml

+5-5
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ mainBuildFilters: &mainBuildFilters
3030
- /^release\/\d+\.\d+\.\d+$/
3131
# use the following branch as well to ensure that v8 snapshot cache updates are fully tested
3232
- 'update-v8-snapshot-cache-on-develop'
33-
- 'breaking/remove_vue_cli_service'
33+
- 'breaking/remove_react_16_17_merge_react18_harness_upstream'
3434
- 'publish-binary'
3535

3636
# usually we don't build Mac app - it takes a long time
@@ -42,7 +42,7 @@ macWorkflowFilters: &darwin-workflow-filters
4242
- equal: [ develop, << pipeline.git.branch >> ]
4343
# use the following branch as well to ensure that v8 snapshot cache updates are fully tested
4444
- equal: [ 'update-v8-snapshot-cache-on-develop', << pipeline.git.branch >> ]
45-
- equal: [ 'breaking/remove_vue_cli_service', << pipeline.git.branch >> ]
45+
- equal: [ 'breaking/remove_react_16_17_merge_react18_harness_upstream', << pipeline.git.branch >> ]
4646
- matches:
4747
pattern: /^release\/\d+\.\d+\.\d+$/
4848
value: << pipeline.git.branch >>
@@ -53,7 +53,7 @@ linuxArm64WorkflowFilters: &linux-arm64-workflow-filters
5353
- equal: [ develop, << pipeline.git.branch >> ]
5454
# use the following branch as well to ensure that v8 snapshot cache updates are fully tested
5555
- equal: [ 'update-v8-snapshot-cache-on-develop', << pipeline.git.branch >> ]
56-
- equal: [ 'breaking/remove_vue_cli_service', << pipeline.git.branch >> ]
56+
- equal: [ 'breaking/remove_react_16_17_merge_react18_harness_upstream', << pipeline.git.branch >> ]
5757
- matches:
5858
pattern: /^release\/\d+\.\d+\.\d+$/
5959
value: << pipeline.git.branch >>
@@ -76,7 +76,7 @@ windowsWorkflowFilters: &windows-workflow-filters
7676
- equal: [ develop, << pipeline.git.branch >> ]
7777
# use the following branch as well to ensure that v8 snapshot cache updates are fully tested
7878
- equal: [ 'update-v8-snapshot-cache-on-develop', << pipeline.git.branch >> ]
79-
- equal: [ 'breaking/remove_vue_cli_service', << pipeline.git.branch >> ]
79+
- equal: [ 'breaking/remove_react_16_17_merge_react18_harness_upstream', << pipeline.git.branch >> ]
8080
- matches:
8181
pattern: /^release\/\d+\.\d+\.\d+$/
8282
value: << pipeline.git.branch >>
@@ -152,7 +152,7 @@ commands:
152152
name: Set environment variable to determine whether or not to persist artifacts
153153
command: |
154154
echo "Setting SHOULD_PERSIST_ARTIFACTS variable"
155-
echo 'if ! [[ "$CIRCLE_BRANCH" != "develop" && "$CIRCLE_BRANCH" != "release/"* && "$CIRCLE_BRANCH" != "breaking/remove_vue_cli_service" ]]; then
155+
echo 'if ! [[ "$CIRCLE_BRANCH" != "develop" && "$CIRCLE_BRANCH" != "release/"* && "$CIRCLE_BRANCH" != "breaking/remove_react_16_17_merge_react18_harness_upstream" ]]; then
156156
export SHOULD_PERSIST_ARTIFACTS=true
157157
fi' >> "$BASH_ENV"
158158
# You must run `setup_should_persist_artifacts` command and be using bash before running this command

CHANGELOG.md

-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
- [`@cypress/eslint-plugin-dev`](https://github.com/cypress-io/cypress/blob/develop/npm/eslint-plugin-dev/CHANGELOG.md)
66
- [`@cypress/mount-utils`](https://github.com/cypress-io/cypress/blob/develop/npm/mount-utils/CHANGELOG.md)
77
- [`@cypress/react`](https://github.com/cypress-io/cypress/blob/develop/npm/react/CHANGELOG.md)
8-
- [`@cypress/react18`](https://github.com/cypress-io/cypress/blob/develop/npm/react18/CHANGELOG.md)
98
- [`@cypress/svelte`](https://github.com/cypress-io/cypress/blob/develop/npm/svelte/CHANGELOG.md)
109
- [`@cypress/vite-dev-server`](https://github.com/cypress-io/cypress/blob/develop/npm/vite-dev-server/CHANGELOG.md)
1110
- [`@cypress/vue`](https://github.com/cypress-io/cypress/blob/develop/npm/vue/CHANGELOG.md)

CONTRIBUTING.md

-1
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,6 @@ Here is a list of the npm packages in this repository:
186186
| [grep](./npm/grep) | `@cypress/grep` | Filter tests using substring |
187187
| [mount-utils](./npm/mount-utils) | `@cypress/mount-utils` | Common functionality for Vue/React/Angular adapters. |
188188
| [react](./npm/react) | `@cypress/react` | Cypress component testing for React. |
189-
| [react18](./npm/react18) | `@cypress/react18` | Cypress component testing for React 18. |
190189
| [schematic](./npm/cypress-schematic) | `@cypress/schematic` | Official Angular Schematic and Builder for the Angular CLI.|
191190
| [svelte](./npm/svelte) | `@cypress/svelte` | Cypress component testing for Svelte. |
192191
| [vite-dev-server](./npm/vite-dev-server) | `@cypress/vite-dev-server` | Vite powered dev server for Component Testing. |

cli/.eslintignore

-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ package.json
1111
# these are all copied from dist'd builds from the individual libs
1212
/angular
1313
/react
14-
/react18
1514
/vue
1615
/svelte
1716
/mount-utils

cli/CHANGELOG.md

+4-2
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,13 @@ _Released 12/3/2024 (PENDING)_
1717
- It is no longer possible to make a `fetch` or `XMLHttpRequest` request from the `about:blank` page in Electron (i.e. `cy.window().then((win) => win.fetch('<some-url>')`). You must use `cy.request` instead or perform some form of initial navigation via `cy.visit()`. Addressed in [#29547](https://github.com/cypress-io/cypress/pull/30394).
1818
- `@cypress/webpack-dev-server` no longer supports `webpack-dev-server` version 3. Additionally, `@cypress/webpack-dev-server` now ships with `webpack-dev-server` version 5 by default. `webpack-dev-server` version 4 will need to be installed along side Cypress if you are still using `webpack` version 4. Addresses [#29308](https://github.com/cypress-io/cypress/issues/29308), [#30347](https://github.com/cypress-io/cypress/issues/30347), and [#30141](https://github.com/cypress-io/cypress/issues/30141).
1919
- `@cypress/vite-dev-server` no longer supports `vite` versions 2 and 3. Addresses [#29377](https://github.com/cypress-io/cypress/issues/29377) and [#29378](https://github.com/cypress-io/cypress/issues/29378).
20-
- Cypress Component Testing no longer supports `Nuxt.js` version 2. Addresses [#30468](https://github.com/cypress-io/cypress/issues/30468).
21-
- Cypress Component Testing no longer supports `Vue` version 2. Addresses [#30295](https://github.com/cypress-io/cypress/issues/30295).
20+
- Cypress Component Testing no longer supports `React` versions 16 and 17. Addresses [#29607](https://github.com/cypress-io/cypress/issues/29607).
2221
- Cypress Component Testing no longer supports `Next.js` versions 10, 11, 12, and 13. Addresses [#29583](https://github.com/cypress-io/cypress/issues/29583).
22+
- Cypress Component Testing no longer supports `Vue` version 2. Addresses [#30295](https://github.com/cypress-io/cypress/issues/30295).
23+
- Cypress Component Testing no longer supports `Nuxt.js` version 2. Addresses [#30468](https://github.com/cypress-io/cypress/issues/30468).
2324
- Cypress Component Testing no longer supports `Angular` versions 13, 14, 15, and 16. The minimum supported version is now `17.2.0` in order to fully support Angular [signals](https://angular.dev/guide/signals). Addresses [#29582](https://github.com/cypress-io/cypress/issues/29582). Addressed in [#30539](https://github.com/cypress-io/cypress/pull/30539).
2425
- Cypress Component Testing no longer supports `Svelte` version 3. Addresses [#30492](https://github.com/cypress-io/cypress/issues/30492).
26+
- The `cypress/react18` test harness is no longer included in the Cypress binary. Instead, React 18 support is now shipped with `cypress/react`! Addresses [#29607](https://github.com/cypress-io/cypress/issues/29607).
2527
- The `cypress/angular-signals` test harness is no longer included in the Cypress binary. Instead, signals support is now shipped with `cypress/angular`! This requires `rxjs` to be installed as a `peerDependency`. Addresses [#29606](https://github.com/cypress-io/cypress/issues/29606).
2628
- Cypress Component Testing no longer supports `create-react-app`. Addresses [#30028](https://github.com/cypress-io/cypress/issues/30028).
2729
- Cypress Component Testing no longer supports `@vue/cli-service`. Addresses [#30481](https://github.com/cypress-io/cypress/issues/30481).

cli/package.json

-7
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@
7171
"@cypress/grep": "0.0.0-development",
7272
"@cypress/mount-utils": "0.0.0-development",
7373
"@cypress/react": "0.0.0-development",
74-
"@cypress/react18": "0.0.0-development",
7574
"@cypress/sinon-chai": "2.9.1",
7675
"@cypress/svelte": "0.0.0-development",
7776
"@cypress/vue": "0.0.0-development",
@@ -114,7 +113,6 @@
114113
"mount-utils",
115114
"vue",
116115
"react",
117-
"react18",
118116
"angular",
119117
"svelte"
120118
],
@@ -145,11 +143,6 @@
145143
"import": "./react/dist/cypress-react.esm-bundler.js",
146144
"require": "./react/dist/cypress-react.cjs.js"
147145
},
148-
"./react18": {
149-
"types": "./react18/dist/index.d.ts",
150-
"import": "./react18/dist/cypress-react.esm-bundler.js",
151-
"require": "./react18/dist/cypress-react.cjs.js"
152-
},
153146
"./mount-utils": {
154147
"types": "./mount-utils/dist/index.d.ts",
155148
"require": "./mount-utils/dist/index.js"

cli/scripts/post-build.js

-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ shell.set('-e') // any error is fatal
99
const npmModulesToCopy = [
1010
'mount-utils',
1111
'react',
12-
'react18',
1312
'vue',
1413
'angular',
1514
'svelte',

npm/react/cypress/component/advanced/app-action-example/counter.cy.jsx

+3-5
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,13 @@ describe('Counter with access', () => {
2020
// the window.counter was set from the Counter's constructor
2121
cy.window()
2222
.should('have.property', 'counter')
23-
.its('state')
24-
.should('deep.equal', { count: 0 })
23+
.its('count')
24+
.should('equal', 0)
2525

2626
// let's change the state of the component
2727
cy.window()
2828
.its('counter')
29-
.invoke('setState', {
30-
count: 101,
31-
})
29+
.invoke('setCount', 101)
3230

3331
// the UI should update to reflect the new count
3432
cy.contains('count: 101').should('be.visible')
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,28 @@
1-
import React from 'react'
1+
import React, { useState } from 'react'
22

3-
export class Counter extends React.Component {
4-
constructor (props) {
5-
super(props)
6-
this.state = {
7-
count: 0,
8-
}
3+
export function Counter () {
4+
const [count, setCount] = useState(0)
95

10-
if (window.Cypress) {
11-
// if this component is mounted from inside Cypress Test Runner
12-
// then expose the reference to this instance
13-
// to allow controlling it from tests
14-
console.log(
15-
'set window.counter to this component in window',
16-
window.location.pathname,
17-
)
6+
if (window.Cypress) {
7+
// if this component is mounted from inside Cypress Test Runner
8+
// then expose the reference to this instance
9+
// to allow controlling it from tests
10+
console.log(
11+
'set window.counter to this component in window',
12+
window.location.pathname,
13+
)
1814

19-
window.counter = this
20-
} else {
21-
console.log('running outside Cypress')
15+
window.counter = {
16+
count,
17+
setCount,
2218
}
19+
} else {
20+
console.log('running outside Cypress')
2321
}
2422

25-
click = () => {
26-
this.setState({
27-
count: this.state.count + 1,
28-
})
23+
function click () {
24+
setCount(count + 1)
2925
}
3026

31-
render () {
32-
return <p onClick={this.click}>count: {this.state.count}</p>
33-
}
27+
return <p onClick={click}>count: {count}</p>
3428
}

npm/react/cypress/component/advanced/context/App.jsx

+9-11
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,13 @@ import React from 'react'
22
import { ThemeContext } from './context'
33
import { Toolbar } from './Toolbar.jsx'
44

5-
export default class App extends React.Component {
6-
render () {
7-
// Use a Provider to pass the current theme to the tree below.
8-
// Any component can read it, no matter how deep it is.
9-
// In this example, we're passing "dark" as the current value.
10-
return (
11-
<ThemeContext.Provider value="dark">
12-
<Toolbar />
13-
</ThemeContext.Provider>
14-
)
15-
}
5+
export default function App () {
6+
// Use a Provider to pass the current theme to the tree below.
7+
// Any component can read it, no matter how deep it is.
8+
// In this example, we're passing "dark" as the current value.
9+
return (
10+
<ThemeContext.Provider value="dark">
11+
<Toolbar />
12+
</ThemeContext.Provider>
13+
)
1614
}

npm/react/cypress/component/advanced/hooks/counter2-with-hooks.jsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export default function Counter2WithHooks () {
66

77
useEffect(() => {
88
document.title = `You clicked ${count} times`
9-
})
9+
}, [count])
1010

1111
return (
1212
<div>
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,28 @@
1-
import React from 'react'
1+
import React, { useState, useEffect } from 'react'
22
// import the entire axios module
33
// later we can use axios.get to make requests
44
import axios from 'axios'
55

6-
export class Users extends React.Component {
7-
constructor (props) {
8-
super(props)
9-
this.state = {
10-
users: [],
11-
}
12-
}
6+
export function Users () {
7+
const [users, setUsers] = useState([])
138

14-
componentDidMount () {
15-
axios
16-
.get('https://jsonplaceholder.cypress.io/users?_limit=3')
17-
.then((response) => {
18-
// JSON responses are automatically parsed.
19-
this.setState({
20-
users: response.data,
21-
})
22-
})
23-
}
9+
const getUsers = async () => {
10+
const response = await axios.get('https://jsonplaceholder.cypress.io/users?_limit=3')
2411

25-
render () {
26-
return (
27-
<div>
28-
{this.state.users.map((user) => (
29-
<li key={user.id}>
30-
<strong>{user.id}</strong> - {user.name}
31-
</li>
32-
))}
33-
</div>
34-
)
12+
setUsers(response.data)
3513
}
14+
15+
useEffect(() => {
16+
getUsers()
17+
}, [])
18+
19+
return (
20+
<div>
21+
{users.map((user) => (
22+
<li key={user.id}>
23+
<strong>{user.id}</strong> - {user.name}
24+
</li>
25+
))}
26+
</div>
27+
)
3628
}

npm/react/cypress/component/advanced/mocking-axios/3-users-api.cy.jsx renamed to npm/react/cypress/component/advanced/mocking-axios/2-users-api.cy.jsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/// <reference types="cypress" />
22
import React from 'react'
33
import { mount } from '@cypress/react'
4-
import { Users } from './3-users-api.jsx'
5-
import * as axios from './axios-api'
4+
import { Users } from './2-users-api.jsx'
5+
import * as axios from './axios-api.jsx'
66

77
describe('Mocking wrapped Axios', () => {
88
it('shows real users', () => {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import React, { useState, useEffect } from 'react'
2+
// import wrapped Axios method
3+
import axiosApi from './axios-api.jsx'
4+
5+
export function Users () {
6+
const [users, setUsers] = useState([])
7+
8+
const getUsers = async () => {
9+
console.log({ axiosApi })
10+
const response = await axiosApi.get('https://jsonplaceholder.cypress.io/users?_limit=3')
11+
12+
setUsers(response.data)
13+
}
14+
15+
useEffect(() => {
16+
getUsers()
17+
}, [])
18+
19+
return (
20+
<div>
21+
{users.map((user) => (
22+
<li key={user.id}>
23+
<strong>{user.id}</strong> - {user.name}
24+
</li>
25+
))}
26+
</div>
27+
)
28+
}

npm/react/cypress/component/advanced/mocking-axios/2-users-named.cy.jsx

-36
This file was deleted.

0 commit comments

Comments
 (0)