Registry / testing / babel-plugin-jsx-property-alias

babel-plugin-jsx-property-alias

JSON →
library2.0.0jsnpmunverified

Babel plugin for aliasing JSX properties, primarily used to map testID to accessibilityLabel for React Native Appium testing. Current stable version is 2.0.0 (2018). Low release cadence; primarily a utility for QA builds. Key differentiator: it solves a specific React Native + Appium incompatibility without polluting production code, and supports environment whitelisting via ALIAS_ENVIRONMENT variable. Alternatives: manual testID duplication, but this plugin automates the transform.

npm install babel-plugin-jsx-property-alias
INSTALL
IMPORT
SIG · BABEL-PLUGIN-JSX-P
B
babel-plugin-jsx-property-alias
testingjavascriptv2.0.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
// In .babelrc or babel.config.js: { "plugins": [ ["jsx-property-alias", { "properties": { "testID": "accessibilityLabel" } }] ] }
// Incorrect: using plugin without array notation { "plugins": ["jsx-property-alias"] }
Plugin must be configured with options in a nested array. Options are required: at least 'properties' key.
require
const plugin = require('babel-plugin-jsx-property-alias');
import plugin from 'babel-plugin-jsx-property-alias'; // ESM not supported in commonjs babel configs
This package is CJS-only; use require() in Node.js. There is no default export.
BABEL_ENV
BABEL_ENV=appium babel src --out-dir build
NODE_ENV=appium babel src --out-dir build // Plugin relies on BABEL_ENV, not NODE_ENV
Plugin uses process.env.BABEL_ENV by default to decide whether to transform. Overridable via includeInEnvironments option and ALIAS_ENVIRONMENT variable.

Configures Babel to replace testID with accessibilityLabel when BABEL_ENV is set to 'appium'.

// Install: npm install --save-dev babel-plugin-jsx-property-alias // .babelrc { "env": { "appium": { "plugins": [ ["jsx-property-alias", { "properties": { "testID": "accessibilityLabel" } }] ] } } } // Then run: BABEL_ENV=appium babel src --out-dir build // Input: <View testID="my_button" /> // Output: <View testID="my_button" accessibilityLabel="my_button" />
Debug
Known issues
breakingVersion 2 changed options format. Old v1 option names and structure no longer work.
fix
Use the new 'properties' object instead of 'from'/'to' arrays. See README for v2 API.
affects: >=2.0.0
gotchaPlugin replaces existing accessibilityLabel if present; no merging.
fix
Ensure that components do not have both testID and accessibilityLabel set manually, or accept that testID will overwrite.
affects: >=1.0.0
gotchaReact Native does not respect BABEL_ENV by default; you must use ALIAS_ENVIRONMENT env var or the includeInEnvironments option.
fix
Set ALIAS_ENVIRONMENT to 'appium' (or your custom env name) in your React Native build scripts.
affects: >=2.0.0
Errors
Common errors & fixes
Error: Cannot find module 'babel-plugin-jsx-property-alias'
Plugin not installed or not in node_modules.
fix
Run 'npm install --save-dev babel-plugin-jsx-property-alias'
TypeError: Cannot read property 'properties' of undefined
Missing options object when adding plugin to Babel config.
fix
Use array syntax: ["jsx-property-alias", { "properties": { ... } }]
Upgrade
Version history
2.0.0latest on npm
Audit
Dependencies
@babel/coreoptionalPeer dependency for Babel plugin API
Agent activity
21 hits · last 30 days
node
18
OpenAI (training)
2
Resources
babel-plugin-jsx-property-alias — npm install babel-plugin-jsx-property-alias · libregistry