-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
breaking: remove support for React 16 and 17 for Cypress Component Te…
…sting. 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]
- Loading branch information
1 parent
53b24b1
commit 0c661b4
Showing
92 changed files
with
618 additions
and
2,051 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
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 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
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
44 changes: 19 additions & 25 deletions
44
npm/react/cypress/component/advanced/app-action-example/counter.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 |
---|---|---|
@@ -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 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
48 changes: 20 additions & 28 deletions
48
npm/react/cypress/component/advanced/mocking-axios/1-users.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 |
---|---|---|
@@ -1,36 +1,28 @@ | ||
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') | ||
|
||
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 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
28 changes: 28 additions & 0 deletions
28
npm/react/cypress/component/advanced/mocking-axios/2-users-api.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,28 @@ | ||
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') | ||
|
||
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.
Oops, something went wrong.
0c661b4
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 build at https://on.cypress.io/advanced-installation#Install-pre-release-version
Run this command to install the pre-release locally:
0c661b4
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 build at https://on.cypress.io/advanced-installation#Install-pre-release-version
Run this command to install the pre-release locally:
0c661b4
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 build at https://on.cypress.io/advanced-installation#Install-pre-release-version
Run this command to install the pre-release locally:
0c661b4
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 build at https://on.cypress.io/advanced-installation#Install-pre-release-version
Run this command to install the pre-release locally:
0c661b4
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 build at https://on.cypress.io/advanced-installation#Install-pre-release-version
Run this command to install the pre-release locally: