Skip to content

Commit 97faa97

Browse files
authored
Update README.md
1 parent efb9d94 commit 97faa97

File tree

1 file changed

+25
-8
lines changed

1 file changed

+25
-8
lines changed

README.md

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
## Babel plugin transform React qa classes
22
[![Build Status](https://travis-ci.org/davesnx/babel-plugin-transform-react-qa-classes.svg?branch=master)](https://travis-ci.org/davesnx/babel-plugin-transform-react-qa-classes) [![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)](http://standardjs.com/) [![npm](https://img.shields.io/npm/dm/localeval.svg)](https://www.npmjs.com/package/babel-plugin-transform-react-qa-classes)
33

4-
This plugin adds the component name as a `data-qa` in each React Component.
4+
This babel plugin adds the component name as a `data-qa` in each React Component.
55

66
<table>
77
<tr>
@@ -38,18 +38,19 @@ class componentName extends Component {
3838
</tr>
3939
</table>
4040

41+
> This plugin asumes that you are using [React](https://reactjs.org) and [Babel](https://babeljs.io) as a building tool to generate your bundle.
42+
4143
### Why?
4244

43-
Basically the idea is to facilitate Automate Testing on Frontend Applications.
44-
Automate Frontend highly requires get the DOMElements and interact with them, adding `data-qa` attributes make it more easy.
45+
The idea is to facilitate Automate Testing on Frontend Applications. Automate Frontend highly requires to get the DOMElements and interact with them, adding `data-qa` attributes automatically to all the components will make it more easy, rather than do it by code, with this way you won't have this `data-qa` in production code.
4546

46-
They would only need to get the element like that:
47+
On the testing site would need to get the element like that:
4748

4849
```js
4950
document.querySelectorAll('[data-qa="component"]')
5051
```
5152

52-
That depends on the Test suit, with [`PageObject`](https://github.com/cheezy/page-object) can work like that:
53+
That depends on the Test suit stack, for example with Ruby and [`PageObject`](https://github.com/cheezy/page-object) looks like that:
5354

5455
```ruby
5556
div(:component, data_qa: 'component')
@@ -74,13 +75,13 @@ npm install --save-dev babel-plugin-transform-react-qa-classes
7475
}
7576
```
7677

77-
> Note: Adding this plugin only on `DEV` mode (or `PREPROD`) allows not having this `data-qa` attributes on production.
78+
> Note: Adding this plugin only on `DEV` mode (or `PREPROD`) allows not having `data-qa` attributes on production.
7879
79-
You can specify the format of the name that you want and the name of the attribute:
80+
You can specify the format of the name that you want and the name of the attribute, inside your `babelrc`:
8081

8182
```json
8283
{
83-
"presets": ["es2015", "react"], // This asumes that you use those presets
84+
"presets": ["es2015", "react"],
8485
"env": {
8586
"dev": {
8687
"plugins": ["transform-react-qa-classes", {
@@ -107,3 +108,19 @@ require('babel-core').transform(`code`, {
107108
plugins: ['transform-react-qa-classes']
108109
})
109110
```
111+
112+
#### Contributing
113+
PRs for additional features are welcome! There's still a few feature that are missing, for example each change of the state of the component is added as a `data-qa-state` into the DOM. Support for more libraries.
114+
115+
I recommend checking this [handbook](https://github.com/jamiebuilds/babel-handbook) about how to write babel plugins in order to learn.
116+
117+
- Clone the repo: `git clone https://github.com/davesnx/babel-plugin-transform-react-qa-classes`
118+
- Fork it & set origin as this repo: `git remote set-url origin https://github.com/YOUR_USERNAME/babel-plugin-transform-react-qa-classes.git`
119+
- Create a branch: `git checkout -b BRANCH_NAME`
120+
- Do the code
121+
- Create a PR to this repo.
122+
123+
There's a githook setted up when you push it runs the tests.
124+
125+
#### License
126+
MIT

0 commit comments

Comments
 (0)