-
Couldn't load subscription status.
- Fork 3.4k
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
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
Merged
Parent:
breaking: 14.0.0 Release
AtofStryker
merged 2 commits into
release/14.0.0
from
breaking/remove_react_16_17_merge_react18_harness_upstream
Nov 15, 2024
Merged
Changes from 1 commit
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,3 +1,3 @@ | ||
| # Bump this version to force CI to re-create the cache from scratch. | ||
|
|
||
| 11-07-24-vue-cli-service-removal | ||
| 11-07-24-react-16-17-removal |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
44 changes: 19 additions & 25 deletions
44
npm/react/cypress/component/advanced/app-action-example/counter.jsx
This file contains hidden or 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,34 +1,28 @@ | ||
| import React from 'react' | ||
| import React, { useState } from 'react' | ||
|
|
||
| export class Counter extends React.Component { | ||
| constructor (props) { | ||
| super(props) | ||
| this.state = { | ||
| count: 0, | ||
| } | ||
| export function Counter () { | ||
| const [count, setCount] = useState(0) | ||
|
|
||
| if (window.Cypress) { | ||
| // if this component is mounted from inside Cypress Test Runner | ||
| // then expose the reference to this instance | ||
| // to allow controlling it from tests | ||
| console.log( | ||
| 'set window.counter to this component in window', | ||
| window.location.pathname, | ||
| ) | ||
| if (window.Cypress) { | ||
| // if this component is mounted from inside Cypress Test Runner | ||
| // then expose the reference to this instance | ||
| // to allow controlling it from tests | ||
| console.log( | ||
| 'set window.counter to this component in window', | ||
| window.location.pathname, | ||
| ) | ||
|
|
||
| window.counter = this | ||
| } else { | ||
| console.log('running outside Cypress') | ||
| window.counter = { | ||
| count, | ||
| setCount, | ||
| } | ||
| } else { | ||
| console.log('running outside Cypress') | ||
| } | ||
|
|
||
| click = () => { | ||
| this.setState({ | ||
| count: this.state.count + 1, | ||
| }) | ||
| function click () { | ||
| setCount(count + 1) | ||
| } | ||
|
|
||
| render () { | ||
| return <p onClick={this.click}>count: {this.state.count}</p> | ||
| } | ||
| return <p onClick={click}>count: {count}</p> | ||
| } |
This file contains hidden or 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
49 changes: 21 additions & 28 deletions
49
npm/react/cypress/component/advanced/mocking-axios/1-users.jsx
This file contains hidden or 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,36 +1,29 @@ | ||
| import React from 'react' | ||
| import React, { useState, useEffect } from 'react' | ||
| // import the entire axios module | ||
| // later we can use axios.get to make requests | ||
| import axios from 'axios' | ||
|
|
||
| export class Users extends React.Component { | ||
| constructor (props) { | ||
| super(props) | ||
| this.state = { | ||
| users: [], | ||
| } | ||
| } | ||
| export function Users () { | ||
| const [users, setUsers] = useState([]) | ||
|
|
||
| componentDidMount () { | ||
| axios | ||
| .get('https://jsonplaceholder.cypress.io/users?_limit=3') | ||
| .then((response) => { | ||
| // JSON responses are automatically parsed. | ||
| this.setState({ | ||
| users: response.data, | ||
| }) | ||
| }) | ||
| } | ||
| const getUsers = async () => { | ||
| const response = await axios.get('https://jsonplaceholder.cypress.io/users?_limit=3') | ||
| // JSON responses are automatically parsed. | ||
|
|
||
| render () { | ||
| return ( | ||
| <div> | ||
| {this.state.users.map((user) => ( | ||
| <li key={user.id}> | ||
| <strong>{user.id}</strong> - {user.name} | ||
| </li> | ||
| ))} | ||
| </div> | ||
| ) | ||
| setUsers(response.data) | ||
| } | ||
|
|
||
| useEffect(() => { | ||
| getUsers() | ||
| }, []) | ||
|
|
||
| return ( | ||
| <div> | ||
| {users.map((user) => ( | ||
| <li key={user.id}> | ||
| <strong>{user.id}</strong> - {user.name} | ||
| </li> | ||
| ))} | ||
| </div> | ||
| ) | ||
| } |
4 changes: 2 additions & 2 deletions
4
...advanced/mocking-axios/3-users-api.cy.jsx → ...advanced/mocking-axios/2-users-api.cy.jsx
This file contains hidden or 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
29 changes: 29 additions & 0 deletions
29
npm/react/cypress/component/advanced/mocking-axios/2-users-api.jsx
This file contains hidden or 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,29 @@ | ||
| import React, { useState, useEffect } from 'react' | ||
| // import wrapped Axios method | ||
| import axiosApi from './axios-api.jsx' | ||
|
|
||
| export function Users () { | ||
| const [users, setUsers] = useState([]) | ||
|
|
||
| const getUsers = async () => { | ||
| console.log({ axiosApi }) | ||
| const response = await axiosApi.get('https://jsonplaceholder.cypress.io/users?_limit=3') | ||
| // JSON responses are automatically parsed. | ||
AtofStryker marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| setUsers(response.data) | ||
| } | ||
|
|
||
| useEffect(() => { | ||
| getUsers() | ||
| }, []) | ||
|
|
||
| return ( | ||
| <div> | ||
| {users.map((user) => ( | ||
| <li key={user.id}> | ||
| <strong>{user.id}</strong> - {user.name} | ||
| </li> | ||
| ))} | ||
| </div> | ||
| ) | ||
| } | ||
36 changes: 0 additions & 36 deletions
36
npm/react/cypress/component/advanced/mocking-axios/2-users-named.cy.jsx
This file was deleted.
Oops, something went wrong.
33 changes: 0 additions & 33 deletions
33
npm/react/cypress/component/advanced/mocking-axios/2-users-named.jsx
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.