@guinie/react-native-testid
TypeScript icon, indicating that this package has built-in type declarations

3.0.0 • Public • Published

@guinie/react-native-testid

A library of utilities for producing test IDs for React Native components.

Table of Contents

Install

npm install @guinie/react-native-testid

API

makeTestIdProps

(testId[, options]) => Object

A utility function for producing test ID props.

@param options – Object: { testIdProps: string[] }

Example:

const { makeTestIdProps } = require('@guinie/react-native-testid')

const MyButton = props => { ... }

const MyParentComponent = props => {
  return (
    <div>
      <MyButton {...makeTestIdProps('my-submit-button')} />
    </div>
  )
}

withTestId

(testId[, options]) => ReactComponentInstance => ReactComponentInstance

A utility function for applying test IDs to React component instances.

@param options – Object: { testIdProps: string[] }

Example:

const { withTestId } = require('@guinie/react-testid')

const MyButton = props => { ... }
const MySubmitButton = withTestId('my--submit-button')(<MyButton />)

const MyParentComponent = props => {
  return (
    <div>
      <MySubmitButton />
    </div>
  )
}

Maintainer

Contributing

For questions, bug reports etc., please open an issue.

Pull requests welcome.

License

ISC 2021

Package Sidebar

Install

npm i @guinie/react-native-testid

Weekly Downloads

1

Version

3.0.0

License

ISC

Unpacked Size

4.29 kB

Total Files

6

Last publish

Collaborators

  • jluukka