-
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 component testing an…
…d move cypress/react18 upstream into cypress/react [run ci] cut over react harness examples to hooks fix failing vite-plugin-cypress-esm tests
- Loading branch information
1 parent
7e45094
commit 1f8d370
Showing
89 changed files
with
609 additions
and
2,042 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
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
49 changes: 21 additions & 28 deletions
49
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,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 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 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' | ||
|
||
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. | ||
|
||
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.
34 changes: 0 additions & 34 deletions
34
npm/react/cypress/component/advanced/mocking-axios/3-users-api.jsx
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.