New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

babel-plugin-format-testid

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babel-plugin-format-testid

A babel plugin to format testIDs in React Native app for running Appium E2E tests

  • 1.0.0
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
40
increased by1900%
Maintainers
1
Weekly downloads
 
Created
Source

Babel Plugin to format testIDs

A babel plugin to format testIDs in React Native app for running Appium E2E tests.

INPUT:
    <Button testID={variable} />
    <Button testID={"asdf"+2} />
    <Button testID="asdf" />
OUTPUT:
    <Button testID={"prefix" + variable} />
    <Button testID={"prefix" + ("asdf" + 2)} />
    <Button testID={"prefix" + "asdf"} />

To setup E2E tests with Appium for the React Native app, we need to format the testIds of components with bundleID as prefix, and to keep the code simple and readable, something like

<Button
    testId="checkout-button"
/>

and not

<Button
    testId="com.example.yourapp:id/checkout-button"
/>

we made this babel plugin which will format the testIds at compile time.

Setup

Step 1: Install the package

    yarn add -D babel-plugin-format-testid

Step 2: Configure plugin babelrc or babel.config.js file

module.exports = {
  presets: [ //... ],
  plugins: [
    [
      'format-testid',
      {
        prefix: 'com.razorpay.payments.app:id/',
        skip: process.env.JEST_WORKER_ID,
      },
    ],
  ],
};

  • prefix (string): This paramter holds the value whihc will be prefixed before every testId

  • skip (boolean): This parameter tells whether the plugin should format the testID or not, for example setting the value process.env.JEST_WORKER_ID means do not format the values when Jest unit tests are running.

Keywords

FAQs

Package last updated on 16 Jan 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc