plugin doesnt remove "data-test-id" attribute
See original GitHub issueIssue Description
Hi!
I use to “react”: “^16.2.0”, webpack 4 install and add plugin into babel’s config
presets: [
'react',
[
'env',
{
modules: false,
useBuiltIns: true,
debug: true,
// будет браться из package.json в версии 1.7 и старше
targets: {
browsers: ['Chrome >= 64', 'Firefox >= 58', 'Safari >= 11', 'iOS >= 10.13', 'Edge >= 41'],
},
},
],
],
plugins: [
'external-helpers',
'syntax-dynamic-import',
'transform-class-properties',
'syntax-trailing-function-commas',
'babel-plugin-jsx-remove-data-test-id',
['transform-object-rest-spread', { useBuiltIns: true }],
[
'lodash',
{
id: ['lodash', 'recompose'],
},
],
],
env: {
development: {
plugins: [
'transform-react-jsx-self',
'transform-react-jsx-source',
[
'babel-plugin-runtyper',
{
enabled: process.env.NODE_ENV !== 'production',
},
],
],
},
production: {
plugins: [
'transform-flow-strip-types',
'transform-react-inline-elements',
'transform-react-remove-prop-types',
'transform-react-constant-elements',
'transform-remove-console',
'transform-remove-debugger',
],
},
}
after building I see in production code this attribute
...
M = Object(C.a)(L.a)((function ({css: a = J.a}) {
const {btn: b} = a
return babelHelpers.jsx('p', {}, void 0, babelHelpers.jsx(F, {
'data-test-id': 'asyncIncrementBtn',
className: b
}, void 0, '+~'), ' ', babelHelpers.jsx(G, {
'data-test-id': 'incrementBtn',
className: b
}, void 0, '+'), ' ', babelHelpers.jsx(H, {'data-test-id': 'decrementBtn', className: b}, void 0, '-'))
})),
...
I also tried to add the plugin in to production section - there is no changes (
Issue Analytics
- State:
- Created 5 years ago
- Comments:11 (7 by maintainers)
Top Results From Across the Web
Babel plugin to remove `data-testid` · Issue #479 - GitHub
This babel plugin will remove data-testid from the rendered HTML. I know it can be done in userland, but it would be nice...
Read more >babel-plugin-jsx-remove-data-test-id - npm
Remove data -test-id attributes from your production builds. Motivation. It's not usually a good idea to couple our test code with DOM element ......
Read more >babel-plugin-remove-data-test-id-attribute - npm package | Snyk
Removes data-test-id attribute from jsx html elements. The data-test-id is normally added for testing as a helper attribute to quickly grab an element...
Read more >Removing data-test Attributes from React Production DOM
The first step is to add the babel-plugin-react-remove-properties package as a dev dependency by running “npm i –save-dev babel-plugin-react- ...
Read more >Create React App 2 - remove html attribute for testing
You can use react-app-rewired ... addBabelPlugins( 'babel-plugin-styled-components', 'babel-plugin-jsx-remove-data-test-id', ), );.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
You may use it. Build the project (to have bundle.js in /dist) and start app
closing due to inactivity, please ping me a message if you need further assistance