Wondering what’s next for npm?Check out our public roadmap! »

taiko-react

0.3.3 • Public • Published

taiko-react Build Status Coverage Status Known Vulnerabilities Greenkeeper badge CircleCI Build status

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

  1. The webpage that is being tested needs to be using React.
  2. 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

Build Status

Repository

taiko-react/taiko-react-functional-tests

Made with 💟 + ☕️ from 🇮🇳

Keywords

Install

npm i taiko-react

DownloadsWeekly Downloads

2

Version

0.3.3

License

Apache-2.0

Unpacked Size

22.4 kB

Total Files

9

Last publish

Collaborators

  • avatar