Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@welldone-software/babel-plugin-react-add-test-id

Package Overview
Dependencies
Maintainers
2
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@welldone-software/babel-plugin-react-add-test-id

Add attribute on react elements

  • 0.0.4
  • latest
  • npm
  • Socket score

Version published
Maintainers
2
Created
Source

babel-plugin-react-add-test-id

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-id="Foo-Wrapper">
    <Bar data-test-id="Foo-Wrapper-Bar">
  </Wrapper>

Install

yarn add @welldone-software/babel-plugin-react-add-test-id

or

npm install @welldone-software/babel-plugin-react-add-test-id

Usage

in .babelrc

"plugins": [
  "@welldone-software/babel-plugin-add-test-id",
  ...

Options

PropertyTypeDefaultDescription
attrNameStringdata-test-idDefine the attribute name
modeStringregularOne of minimal, regular, full
ignoreElementsArray of Strings[div, input, a, button, span, p, br, hr, ul, ol, li, img, form, h1, h2, h3, h4, h5, h6, svg, path, g]Avoid adding test id on those elements
additionalIgnoreElementsArray of Strings[]Add extra ignoreElements
delimiterString-Separate components name with the delimiter

in .babelrc

"plugins": [
  ["@welldone-software/babel-plugin-add-test-id", {"attrName": "data-test-id-example"}],

Keywords

FAQs

Package last updated on 18 Mar 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc