{"id":18831,"library":"strip-test-selectors","title":"strip-test-selectors","description":"A Babel plugin that strips data-test-* attributes from Ember.js templates and properties from JavaScript objects in production builds. Current stable version is 0.1.0, released as part of the ember-test-selectors monorepo. It is designed for Embroider+Vite apps (Ember 3.28+, Ember CLI 4.12+, Node.js 18+). Unlike the classic ember-test-selectors addon which works with classic Ember builds, this package provides granular Babel plugins for Vite-based setups, giving developers control over when stripping occurs via environment variables.","status":"active","version":"0.1.0","language":"javascript","source_language":"en","source_url":"https://github.com/mainmatter/ember-test-selectors","tags":["javascript"],"install":[{"cmd":"npm install strip-test-selectors","lang":"bash","label":"npm"},{"cmd":"yarn add strip-test-selectors","lang":"bash","label":"yarn"},{"cmd":"pnpm add strip-test-selectors","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Required to transform Ember templates and apply AST transforms for stripping data-test attributes.","package":"babel-plugin-ember-template-compilation","optional":false}],"imports":[{"note":"ESM import is preferred but CommonJS require works if using CJS. The plugin strips data-test-* properties from JavaScript objects.","wrong":"const stripPropertiesPlugin = require('strip-test-selectors').stripPropertiesPlugin","symbol":"stripPropertiesPlugin","correct":"import { stripPropertiesPlugin } from 'strip-test-selectors'"},{"note":"The default export is the AST transform plugin for stripping data-test-* attributes from templates. Named import will fail.","wrong":"import { stripTestSelectors } from 'strip-test-selectors'","symbol":"default (AST transform plugin)","correct":"import stripTestSelectors from 'strip-test-selectors'"},{"note":"Type imports should use 'import type' to avoid runtime import. The library ships TypeScript declarations.","wrong":"import { StripTestSelectorsPlugin } from 'strip-test-selectors'","symbol":"types","correct":"import type { StripTestSelectorsPlugin } from 'strip-test-selectors'"}],"quickstart":{"code":"// babel.config.cjs\nconst { stripPropertiesPlugin } = require('strip-test-selectors');\n\nmodule.exports = {\n  plugins: [\n    [\n      'babel-plugin-ember-template-compilation',\n      {\n        compilerPath: 'ember-source/dist/ember-template-compiler.js',\n        enableLegacyModules: ['@ember/template-compiler'],\n        transforms: [\n          ...(process.env.STRIP_TEST_SELECTORS ? [require('strip-test-selectors').default] : []),\n        ],\n      },\n    ],\n    ...(process.env.STRIP_TEST_SELECTORS ? [stripPropertiesPlugin] : []),\n  ],\n};","lang":"javascript","description":"Configures Babel to strip data-test-* from templates and JS objects only when STRIP_TEST_SELECTORS environment variable is set, typically for production builds."},"warnings":[{"fix":"Use ember-test-selectors package for classic Ember apps, or migrate to Embroider+Vite.","message":"This package only works with Embroider+Vite apps, not classic Ember builds. Classic builds must use ember-test-selectors addon.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Use import stripTestSelectors from 'strip-test-selectors' for the template plugin.","message":"The default export is the AST transform for templates, not a named export. Doing import { stripTestSelectors } will fail with 'undefined'.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Update Node.js to 18+ and Ember to 3.28+.","message":"Requires Node.js 18+ and Ember 3.28+. Older versions are not supported.","severity":"breaking","affected_versions":">=0.1.0"},{"fix":"Set STRIP_TEST_SELECTORS=true in your production build script.","message":"You are responsible for configuring when stripping occurs via environment variable; there is no automatic production detection.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Use data-test-* prefix for all test selectors.","message":"The plugin only strips attributes starting with 'data-test-'. Custom prefixes or suffixes are not supported.","severity":"gotcha","affected_versions":">=0.1.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Use stripPropertiesPlugin as a named export: import { stripPropertiesPlugin } from 'strip-test-selectors'","cause":"Using old named import syntax for default export or incorrect package path.","error":"TypeError: Cannot destructure property 'stripPropertiesPlugin' of 'require(...)' as it is undefined."},{"fix":"Install it: npm install -D babel-plugin-ember-template-compilation","cause":"Missing peer dependency babel-plugin-ember-template-compilation.","error":"Error: Cannot find module 'babel-plugin-ember-template-compilation'"},{"fix":"Provide transforms array in plugin options, e.g., transforms: [stripTestSelectors]","cause":"babel-plugin-ember-template-compilation config missing transforms array.","error":"AssertionError [ERR_ASSERTION]: The plugin expected an object for 'transforms', got undefined."}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}