esbuild-plugin-removetestid

raw JSON →
0.0.5 verified Fri May 01 auth: no javascript deprecated

ESBuild plugin to remove data-testid attributes from JSX/TSX during build. Current version is 0.0.5 (no recent updates, appears unmaintained). The author deprecated it in favor of esbuild-plugin-react18, which provides additional options and control. Differentiator: simple API but deprecated and superseded by a more comprehensive plugin.

error Error: Cannot find module 'esbuild-plugin-removetestid'
cause Package not installed or missing from node_modules.
fix
Run 'npm install esbuild-plugin-removetestid' or check that dependency is listed in package.json.
error TypeError: removeTestidPlugin is not a function
cause Incorrect import; likely using named import but plugin is default export.
fix
Use 'import removeTestidPlugin from "esbuild-plugin-removetestid"'.
deprecated Package is deprecated in favor of esbuild-plugin-react18
fix Switch to esbuild-plugin-react18, which offers more features and control.
gotcha Only removes data-testid attributes; does not handle other test attributes like data-test or data-cy
fix Use esbuild-plugin-react18 or configure custom attribute if needed.
gotcha Plugin only works with JSX/TSX files; does not strip testids from JavaScript files that generate JSX
fix Ensure your JSX/TSX files are properly configured as esbuild's 'tsx' or 'jsx' loader.
npm install esbuild-plugin-removetestid
yarn add esbuild-plugin-removetestid
pnpm add esbuild-plugin-removetestid

Example tsup configuration using the plugin to remove data-testid attributes from output during build.

// tsup.config.ts
import { defineConfig } from 'tsup';
import removeTestidPlugin from 'esbuild-plugin-removetestid';

export default defineConfig({
  entry: ['src/index.tsx'],
  format: ['cjs', 'esm'],
  esbuildPlugins: [removeTestidPlugin()],
});