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

@vijaypjavvadi/pw-emit

v1.3.0

Published

Shared emitter library that renders Playwright TypeScript Page Objects, spec files, and project scaffolds from a generic IR. Powers both @vijaypjavvadi/sel2pw and @vijaypjavvadi/bdd2pw.

Readme

@vijaypjavvadi/pw-emit

Shared emitter library that renders Playwright TypeScript Page Objects, spec files, and project scaffolds from a generic IR.

License: MIT

Powers both @vijaypjavvadi/sel2pw (planned, post-v1.0) and @vijaypjavvadi/bdd2pw (from day one).

Why this exists

Both sel2pw (Selenium Java → Playwright TS) and bdd2pw (Gherkin → Playwright TS) need to emit the same shape of Page Objects, spec files, and project scaffolds. Without this package, they'd have two copies of the emitter — and divergence would be inevitable.

pw-emit is the single source of truth for what a generated Playwright TS file looks like. It does not parse Java, does not parse Gherkin — its inputs are clean IRs, and it produces TypeScript strings.

Install

npm install @vijaypjavvadi/pw-emit

Peer dep: the target project (the one being scaffolded) needs @playwright/test ≥ 1.40 — but pw-emit itself doesn't.

Quick example

import { emitPageObject, type PageObjectIR } from "@vijaypjavvadi/pw-emit";

const ir: PageObjectIR = {
  className: "LoginPage",
  fields: [
    { api: "getByLabel", args: "'Username'", fieldName: "usernameInput" },
    { api: "getByLabel", args: "'Password'", fieldName: "passwordInput" },
    { api: "getByRole", args: "'button', { name: 'Sign in' }", fieldName: "signInButton" },
  ],
  methods: [
    {
      name: "login",
      params: [{ name: "user", type: "string" }, { name: "pass", type: "string" }],
      body: "await this.usernameInput.fill(user);\nawait this.passwordInput.fill(pass);\nawait this.signInButton.click();",
    },
  ],
};

const result = emitPageObject(ir);
console.log(result.contents);

Produces:

import { Page, Locator, expect } from "@playwright/test";

export class LoginPage {
  readonly page: Page;
  readonly usernameInput: Locator;
  readonly passwordInput: Locator;
  readonly signInButton: Locator;

  constructor(page: Page) {
    this.page = page;
    this.usernameInput = page.getByLabel("Username");
    this.passwordInput = page.getByLabel("Password");
    this.signInButton = page.getByRole("button", { name: "Sign in" });
  }

  async login(user: string, pass: string): Promise<void> {
    await this.usernameInput.fill(user);
    await this.passwordInput.fill(pass);
    await this.signInButton.click();
  }
}

Public API

Emitters

emitPageObject(ir: PageObjectIR, opts?: { selfHealingShim?: boolean }): EmitResult;
emitTestSpec(ir: TestSpecIR): EmitResult;
emitProject(opts: {
  outDir: string;
  templatesDir?: string;       // override the built-in templates
  baseUrl?: string;            // injected into playwright.config.ts
  projectName?: string;        // injected into package.json
}): Promise<{ filesWritten: string[]; warnings: ReviewItem[] }>;

Locator rendering

renderLocatorExpr(choice: LocatorChoice, pageVar?: string): string;
renderFieldDeclaration(choice: LocatorChoice): string;       // "  readonly foo: Locator;"
renderFieldAssignment(choice: LocatorChoice, pageVar?: string): string;

Naming + indent

toCamelCase(s: string): string;
toKebabCase(s: string): string;
toPascalCase(s: string): string;
pageObjectFileName(className: string): string;   // "LoginPage" → "login.page.ts"
testFileName(className: string): string;          // "LoginTest" → "login.spec.ts"
dedentAndIndent(body: string, prefix: string): string;

IR types

PageObjectIR, PomMethodIR, LocatorChoice, TestSpecIR, TestCaseIR, ReviewItem, EmitResult — all exported from the root.

Design rule that makes this work

Method bodies arrive pre-rendered. pw-emit does not transform method bodies — it places them inside a class wrapper, indents them correctly, and worries about imports. Each consumer (sel2pw, bdd2pw) is responsible for producing valid TS body strings from its own input.

This is the single decision that lets sel2pw (which rewrites raw Java method bodies) and bdd2pw (which assembles bodies from Gherkin step bindings) share an emitter without one having to know about the other's input format.

SemVer commitments

  • Patch: bug fixes, additive warnings, formatting tweaks.
  • Minor: new exported helpers, new optional input fields (defaulted).
  • Major: any change to the emitted file shape (POM/spec format), required input fields, or removed exports.

License

MIT