0.0.9 • Published 2 years ago

unplugin-clear-testid v0.0.9

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

unplugin-clear-testid

NPM version

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

Install

yarn add -D unplugin-clear-testid
// 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.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.config.js
module.exports = {
  /* ... */
  plugins: [
    require('unplugin-clear-testid/webpack')({
      attrs: ['data-testid', 'data-cy'],
      testing: process.env.NODE_ENV === 'testing'
    })
  ]
}

// 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.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
}
0.0.9

2 years ago

0.0.8

2 years ago

0.0.7

2 years ago

0.0.6

2 years ago

0.0.5

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago