3.0.0 • Published 2 years ago

@guinie/react-testid v3.0.0

Weekly downloads
37
License
ISC
Repository
github
Last release
2 years ago

@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

3.0.0

2 years ago

2.0.1

3 years ago

2.0.0

3 years ago

0.2.3

3 years ago

0.2.2

3 years ago

0.2.1

3 years ago

0.2.0

3 years ago