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

create-test-id

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

create-test-id

Creates typed testId for autotests

  • 0.0.5
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3
increased by50%
Maintainers
1
Weekly downloads
 
Created
Source

create-test-id

NPM version dependencies: none code style: prettier TypeScript Conventional Commits License MIT

Creates typed testId for autotests.

Install

Requires node version 16 or higher:

npm install create-test-id

Usage

In TypeScript module label.tsx with component Label:

import createTestId from 'create-test-id';
// or
import {createTestId} from 'create-test-id';

import {inputTestId} from 'components/Input';

export const labelTestId = createTestId<{input: typeof inputTestId; text: unknown}>();

labelTestId.input = inputTestId;

export const Label = () => {
  ...

  return (
    <div data-testid={labelTestId}>
      ...
      <span data-testid={labelTestId.text}>...<span>
    </div>
  );
};

In TypeScript module App.tsx with root component App:

import {labelTestId} from 'components/Label';

export const appTestId = createTestId<{label: typeof labelTestId; header: unknown}>('fooWebApp');

appTestId.label = labelTestId;

For production you can use createTestIdForProduction. This function has the same API as createTestId, but does not create new objects, and its testId is always equal to the empty string.

import {createTestId as createTestIdForDev, createTestIdForProduction} from 'create-test-id';

export const createTestId = __IS_PRODUCTION__ ? createTestIdForProduction : createTestIdForDev;

License

MIT

Keywords

FAQs

Package last updated on 31 May 2022

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