babel plugin for react data-testid attributes
npm install babel-plugin-react-data-testid



> babel plugin for react data-testid attributes
```
$ npm install --save-dev babel-plugin-react-data-testid
$ yarn add --dev babel-plugin-react-data-testid
.babelrc.json
`json`
{
"plugins": ["react-data-testid"]
}
Before:
`js
function Div() {
return
}
const Hello = () =>
After:
`js
function Div() {
return
}const Hello = () =>
hello
`_Note_: Does not support class components.
$3
#### attributes
By default attributes with name
data-testid will be added. You can also define custom attribute names via plugin options in your babel config..babelrc.json
`json
{
"plugins": [["react-data-testid", { "attributes": ["data-cy"] }]]
}
``js
function Div() {
return
}const Hello = () =>
hello
`After:
`js
function Div() {
return
}const Hello = () =>
hello
`If you need to add multiple attributes, you can define an attributes array as follows:
`json
{
"plugins": [
["react-data-testid", { "attributes": ["data-testid", "data-cy"] }]
]
}
``Thanks goes to these wonderful people (emoji key):
akameco 💻 📖 🚇 ⚠️ |
This project follows the all-contributors specification. Contributions of any kind welcome!
MIT © akameco