GithubHelp home page GithubHelp logo

babel-plugin-react-add-test-id's Introduction

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

Property Type Default Description
attrName String data-test-id Define the attribute name
mode String regular One of minimal, regular, full
ignoreElements Array 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
additionalIgnoreElements Array of Strings [] Add extra ignoreElements
delimiter String - Separate components name with the delimiter

in .babelrc

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

babel-plugin-react-add-test-id's People

Contributors

nir-welldone avatar shahafa avatar vzaidman avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

babel-plugin-react-add-test-id's Issues

Module build failed

After following your installation instructions, I got this error while building my react app:
ERROR in ./src/index.tsx
Module build failed (from ./node_modules/babel-loader/lib/index.js):
Error: Cannot find module '@welldone-software/babel-plugin-add-test-id' from '/home/user/webapp'

Shouldn't it look for it the node_modules folder?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.