question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

plugin doesnt remove "data-test-id" attribute

See original GitHub issue

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:closed
  • Created 6 years ago
  • Comments:11 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
budarincommented, Apr 9, 2018

You may use it. Build the project (to have bundle.js in /dist) and start app

0reactions
coderascommented, Sep 7, 2018

closing due to inactivity, please ping me a message if you need further assistance

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found