Security News
JSR Working Group Kicks Off with Ambitious Roadmap and Plans for Open Governance
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
babel-plugin-transform-react-qa-classes
Advanced tools
Add component's name in `data-qa` attributes to React Components Edit
This plugin adds the component name as a data-qa
in each React Component.
Before | After |
---|---|
class componentName extends Component { render () { return ( <div> <div>Hello world</div> </div> ) } } |
class componentName extends Component { render () { return ( <div data-qa='component-name'> <div>Hello world</div> </div> ) } } |
Basically the idea is to facilitate Automate Testing on Frontend Applications.
Automate Frontend highly requires get the DOMElements and interact with them, adding data-qa
attributes make it more easy.
They would only need to get the element like that:
document.querySelectorAll('[data-qa="component"]')
That depends on the Test suit, with PageObject
can work like that:
div(:component, data_qa: 'component')
npm install --save-dev babel-plugin-transform-react-qa-classes
# or yarn add -d
.babelrc
{
"presets": ["es2015", "react"], // This asumes that you use those presets
"env": {
"dev": {
"plugins": ["transform-react-qa-classes"]
}
}
}
Note: Adding this plugin only on
DEV
mode (orPREPROD
) allows not having thisdata-qa
attributes on production.
You can specify the format of the name that you want and the name of the attribute:
{
"presets": ["es2015", "react"], // This asumes that you use those presets
"env": {
"dev": {
"plugins": ["transform-react-qa-classes", {
"attribute": "qa-property",
"format": "camelCase"
}]
}
}
}
Note: format can be: "camel" (camelCase), "snake" (snake_case) or "kebab" (kebab-case).
babel --plugins transform-react-qa-classes component.js
require('babel-core').transform(`code`, {
plugins: ['transform-react-qa-classes']
})
This plugin is in a early stage and potentially can change, I will follow semVer convention. Even the name isn't declarative for what it does and it just solves one problem with QA Automate, can be more generic.
It's extremly dummy for now but you can get an idea on the (tests)[test/README.md]
FAQs
Add component's name in `data-qa` attributes to React Components Edit
The npm package babel-plugin-transform-react-qa-classes receives a total of 9,638 weekly downloads. As such, babel-plugin-transform-react-qa-classes popularity was classified as popular.
We found that babel-plugin-transform-react-qa-classes demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
Security News
Research
An advanced npm supply chain attack is leveraging Ethereum smart contracts for decentralized, persistent malware control, evading traditional defenses.
Security News
Research
Attackers are impersonating Sindre Sorhus on npm with a fake 'chalk-node' package containing a malicious backdoor to compromise developers' projects.