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

3.0.0 • Public • Published

@guinie/react-testid

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

Table of Contents

Install

npm install @guinie/react-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-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

/@guinie/react-testid/

    Package Sidebar

    Install

    npm i @guinie/react-testid

    Weekly Downloads

    1

    Version

    3.0.0

    License

    ISC

    Unpacked Size

    3.95 kB

    Total Files

    6

    Last publish

    Collaborators

    • jluukka