babel-plugin-react-add-data-attribute
TypeScript icon, indicating that this package has built-in type declarations

1.1.1 • Public • Published

babel-plugin-react-data-testid

Build Status tested with jest styled with prettier

Example

in

const Foo = () =>
  <Bar>
    <div>
  </Bar>

out

const Foo = () =>
  <Bar data-test-id="Foo-Bar">
    <div data-test-id="Foo-Bar-div">
  </Bar>

Useful with styled-components

in

const Wrapper = styled.div`...`

const Bar = styled.div`...`

const Foo = () =>
  <Wrapper>
    <Bar>
  </Wrapper>

out

const Wrapper = styled.div`...`

const Bar = styled.div`...`

const Foo = () =>
  <Wrapper data-test="Foo-Wrapper">
    <Bar data-test="Foo-Wrapper-Bar">
  </Wrapper>

Install

yarn add davidgustys/babel-plugin-react-add-data-attribute

or

npm install davidgustys/babel-plugin-react-add-data-attribute

Usage

in .babelrc

"plugins": [
  "davidgustys/babel-plugin-react-add-data-attribute",
  ...

Package Sidebar

Install

npm i babel-plugin-react-add-data-attribute

Weekly Downloads

17

Version

1.1.1

License

MIT

Unpacked Size

11.1 kB

Total Files

5

Last publish

Collaborators

  • davidgustys