npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

e2e-testid

v1.0.4

Published

A small utility for stable and consistent data-testid generation for E2E testing.

Downloads

225

Readme

Here is a clean, professional README.md you can use for your package:


e2e-testid

A lightweight utility for generating stable and consistent data-testid values for E2E testing.

It helps teams standardize selectors, avoid flaky tests, and create namespaced test IDs in a clean and scalable way.


✨ Why e2e-testid?

E2E tests often break because:

  • Selectors are inconsistent
  • Developers rename classes
  • IDs are not standardized
  • There is no naming convention

e2e-testid solves this by providing:

  • Consistent data-testid naming
  • Namespacing support (Auth.Login.Submit)
  • Automatic test id builder per feature
  • Optional runtime toggle (enable only in E2E builds)

📦 Installation

npm install e2e-testid

or

yarn add e2e-testid

🚀 Basic Usage

const { tid } = require("e2e-testid");

<button {...tid("Auth.Login.Submit")}>
  Login
</button>

Output:

<button data-testid="Auth.Login.Submit">
  Login
</button>

🏗 Namespaced Builder

Create a namespace for a feature:

const { createTid } = require("e2e-testid");

const t = createTid("Auth.Login");

<button {...t.tid("Submit")}>
  Login
</button>

Result:

<button data-testid="Auth.Login.Submit">

🔁 Child Namespaces

const auth = createTid("Auth");
const login = auth.child("Login");

login.tid("Submit");

Generates:

Auth.Login.Submit

⚙️ Enable / Disable Test IDs

You can enable test IDs only in E2E environments:

const { configure } = require("e2e-testid");

configure({ enabled: true });

Or automatically enable using environment variable:

E2E=true

This prevents data-testid from being included in production builds if desired.


🧠 Recommended Naming Convention

Use structured names:

Feature.Screen.Element

Examples:

Auth.Login.EmailInput
Auth.Login.Submit
Cart.Checkout.Total
Checkout.Success.Message

This keeps your test suite readable and scalable.


🎯 Works With

  • Playwright
  • Cypress
  • Selenium
  • Any E2E framework

📌 Example With Playwright

await page.getByTestId("Auth.Login.Submit").click();

📄 License

ISC