taiko-react
v0.3.3
Published
React selectors for Taiko
Downloads
4
Readme
taiko-react
taiko-react
allows you to select React components on the webpage that you want to perform tests on.
It uses resq to find the React components.
Pre-requisites
- The webpage that is being tested needs to be using React.
- React needs to be running in development mode (not production).
Install
npm i taiko-react
Usage
Load up the plugin and navigate to the React powered webpage ⚡️
const { openBrowser, goto, loadPlugin } = require('taiko')
const { ID, clientHandler, react } = require('taiko-react')
await loadPlugin(ID, clientHandler)
await openBrowser()
await goto("http://localhost:8080")
Now you may use various selectors to find React elements on the page 🔎
Select using a string
const selection = await react('App')
Select using a React component class
class App extends React.Component {/* ... */}
const selection = await react(App)
Select using a function
function App() {
return <div>Hello world!</div>
}
const selection = await react(App)
Select using a React component instance
const selection = await react(<App />)
API
.exists()
-> Boolean
Checks whether the component exists.
const selection = await react(App)
assert(selection.exists())
.length()
-> Number
Finds the number of said components.
const list = await react(List)
const listItem = await react(ListItem, { multiple: true })
assert(list.length() === 1)
assert(listItem.length() === 3)
Functional tests
Status
Repository
taiko-react/taiko-react-functional-tests
Made with 💟 + ☕️ from 🇮🇳