This package has been deprecated

Author message:

Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

unplugin-clear-testid
TypeScript icon, indicating that this package has built-in type declarations

0.0.9 • Public • Published

unplugin-clear-testid

NPM version

Simple unplugin which removes data-testid & data-cy from your code.

Install

yarn add -D unplugin-clear-testid
Vite
// vite.config.ts
import ClearTestid from 'unplugin-clear-testid/vite'

export default defineConfig({
  plugins: [
    ClearTestid({
      attrs: ['data-testid', 'data-cy'],
      testing: process.env.NODE_ENV === 'testing'
    }),
  ],
})

Example: playground/


Rollup
// rollup.config.js
import Starter from 'unplugin-clear-testid/rollup'

export default {
  plugins: [
    Starter({
      attrs: ['data-testid', 'data-cy'],
      testing: process.env.NODE_ENV === 'testing'
    }),
  ],
}


Webpack
// webpack.config.js
module.exports = {
  /* ... */
  plugins: [
    require('unplugin-clear-testid/webpack')({
      attrs: ['data-testid', 'data-cy'],
      testing: process.env.NODE_ENV === 'testing'
    })
  ]
}


Nuxt
// nuxt.config.js
export default {
  buildModules: [
    ['unplugin-clear-testid/nuxt', {
      attrs: ['data-testid', 'data-cy'],
      testing: process.env.NODE_ENV === 'testing'
    }],
  ],
}

This module works for both Nuxt 2 and Nuxt Vite


Vue CLI
// vue.config.js
module.exports = {
  configureWebpack: {
    plugins: [
      require('unplugin-clear-testid/webpack')({
        attrs: ['data-testid', 'data-cy'],
        testing: process.env.NODE_ENV === 'testing'
      }),
    ],
  },
}


Options

There are only two options which allows you to customize data attributes you want to remove and boolean flag to determine it is testing environment or not. Below there are default values:

{
  attrs: ['data-testid', 'data-cy'],
  testing: false
}

Package Sidebar

Install

npm i unplugin-clear-testid

Weekly Downloads

14

Version

0.0.9

License

MIT

Unpacked Size

13.6 kB

Total Files

36

Last publish

Collaborators

  • grixu