@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