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

@wpsyntex/e2e-test-utils

v0.1.0

Published

End-to-end test utilities for Polylang projects.

Readme

🧪 Polylang E2E Test Utils

This package provides shared E2E testing utilities for Polylang projects.

📦 Installation

npm install --save-dev @wpsyntex/e2e-test-utils @playwright/test @wordpress/e2e-test-utils-playwright

Peer dependencies (required in consuming projects):

  • @playwright/test
  • @wordpress/e2e-test-utils-playwright

When installing from the GitHub repository, the prepare script builds the package automatically. When installing from npm, the published tarball already includes the compiled build/ output.

🛠 Development

When working on this package locally:

npm install --omit=peer
npm run build
npm install @playwright/test @wordpress/e2e-test-utils-playwright
npm run lint:js
node -e "require('@wpsyntex/e2e-test-utils')"

Run npm run build after changing files in src/. The build/ directory is not committed; it is generated by prepare on install and by prepublishOnly before publishing.

🚀 Usage

⚙️ Playwright configuration

Create a playwright.config.mjs file in your E2E test directory:

import { getPlaywrightConfig } from '@wpsyntex/e2e-test-utils';

export default getPlaywrightConfig( {
  globalSetup: './global.setup.mjs',
  globalTeardown: './global.teardown.mjs',
} );

getPlaywrightConfig() merges your options with sensible defaults (Chromium, HTML reporter, wp-env web server, storage state path, etc.). The default globalSetup points to the packaged build/setup/global.setup.cjs when not overridden.

Configuration Options

The getPlaywrightConfig function accepts an options object that can override any of the default configuration:

  • use: Override default Playwright use options
  • webServer: Override default webServer configuration
  • Any other Playwright configuration options

Default Configuration

The default configuration includes:

  • Chrome browser setup
  • HTML reporter
  • CI-specific settings
  • Default storage state path
  • Local development server configuration

📚 API Documentation

🌐 Language Management Functions

getAllLanguages( requestUtils )

Retrieves a list of all configured languages in Polylang.

  • Parameters:
    • requestUtils: Gutenberg request utils object
  • Returns: Promise resolving to the list of languages
getLanguage( requestUtils, slug )

Retrieves a specific language by its slug.

  • Parameters:
    • requestUtils: Gutenberg request utils object
    • slug: Language slug to retrieve
  • Returns: Promise resolving to the language data
createLanguage( requestUtils, locale )

Creates a new language in Polylang.

  • Parameters:
    • requestUtils: Gutenberg request utils object
    • locale: Language locale to create (e.g., 'fr_FR')
  • Returns: Promise resolving to the created language
deleteLanguage( requestUtils, slug )

Deletes a specific language by its slug.

  • Parameters:
    • requestUtils: Gutenberg request utils object
    • slug: Language slug to delete
  • Returns: Promise resolving to the deletion result
deleteAllLanguages( requestUtils )

Deletes all configured languages except the default one.

  • Parameters:
    • requestUtils: Gutenberg request utils object
  • Returns: Promise resolving to the deletion results

⚙️ Settings Management Functions

getSettings( requestUtils )

Retrieves all Polylang plugin settings.

  • Parameters:
    • requestUtils: Gutenberg request utils object
  • Returns: Promise resolving to the settings object
setSetting( requestUtils, settingKey, settingValue )

Updates a specific plugin setting.

  • Parameters:
    • requestUtils: Gutenberg request utils object
    • settingKey: The key of the setting to update
    • settingValue: The new value for the setting
  • Returns: Promise resolving to the updated setting
resetAllSettings( requestUtils )

Resets all plugin settings to their default values.

  • Parameters:
    • requestUtils: Gutenberg request utils object
  • Returns: Promise resolving to the reset operation result
  • Note: Preserves the default language setting

🏷️ Taxonomy Management Functions

getAllTerms( requestUtils, taxonomy )

Retrieves all terms for a specific taxonomy.

  • Parameters:
    • requestUtils: Gutenberg request utils object
    • taxonomy: Taxonomy slug
  • Returns: Promise resolving to the list of terms
getTermBySlug( requestUtils, taxonomy, slug )

Retrieves a specific term by its slug within a taxonomy.

  • Parameters:
    • requestUtils: Gutenberg request utils object
    • taxonomy: Taxonomy slug
    • slug: Term slug to retrieve
  • Returns: Promise resolving to the term data
deleteAllTerms( requestUtils, taxonomy )

Deletes all terms within a specific taxonomy.

  • Parameters:
    • requestUtils: Gutenberg request utils object
    • taxonomy: Taxonomy slug
  • Returns: Promise resolving to the deletion results

📄 XLIFF Export Functions

fillInXliffExportForm( page, options )

Fills in the XLIFF export form for bulk translation export.

  • Parameters:
    • page: Playwright page object
    • options: Configuration object
      • postId: Post ID to export
      • postTitle: Post title to select
      • languageName: Target language name
  • Returns: Promise that resolves when the export form is submitted
  • Note: Page should be on the post list table
getXliffRegex( sourceLocale, targetLocale )

Returns a regex pattern to match XLIFF file names with the specified locales and timestamp.

  • Parameters:
    • sourceLocale: Source language locale (e.g., 'en_US')
    • targetLocale: Target language locale (e.g., 'fr_FR')
  • Returns: RegExp object to match XLIFF file names
  • Note: Converts underscores to hyphens in locales and matches timestamp pattern

📥 Download Utilities

getDownload( page, submitButtonOptions )

Returns a download promise by clicking a submit button and waiting for the download to start.

  • Parameters:
    • page: Playwright page object
    • submitButtonOptions: Submit button options (default: { name: 'Submit' })
  • Returns: Promise resolving to the download object
getStringFromFile( filePath )

Reads a file and returns its contents as a string.

  • Parameters:
    • filePath: The file path to read
  • Returns: String content of the file

🔧 Additional Exports

globalSetup

Global setup function for Playwright tests. Ensures fixtures are deleted and global context is set up properly.

👤 User Utilities

createTranslator( langSlugs, userName = '' )

Creates a translator user, based on the editor role.

  • Parameters:
    • langSlugs: List of language slugs.
    • userName: Optional. A user name. Defaults to XX-YY-translator, where XX and YY are language slugs.
  • Returns: Promise resolving to a user object containing ID, user name, and password.
switchToUser( user, admin, requestUtils )

Switches to the given user.

  • Parameters:
    • user: The user to switch to (an object containing a user name and a password).
    • admin: Instance of Admin.
    • requestUtils: Gutenberg request utils object.
  • Returns: Promise resolving to the Page object.

💡 Usage Example

import {
  createLanguage,
  setSetting,
  getAllTerms
} from '@wpsyntex/e2e-test-utils';

// Create a new language
await createLanguage( requestUtils, 'fr_FR' );

// Update a setting
await setSetting( requestUtils, 'hide_default', true );

// Get all terms from a taxonomy
const terms = await getAllTerms( requestUtils, 'category' );

All these functions are designed to work with the Gutenberg request utils object and follow REST API patterns for interacting with Polylang's functionality. They provide a comprehensive set of tools for managing languages, settings, and taxonomies in E2E tests.

📤 Publishing

The Publish to npm workflow reuses Static Analysis (build, lint, smoke test) before publishing.

Repository secret required: NPM_TOKEN (npm access token with publish rights for @wpsyntex).

Stable releases (latest)

Triggered when a GitHub release is published:

  1. Bump the version in package.json.
  2. Create a git tag matching the version (e.g. v0.2.0).
  3. Publish a GitHub release from that tag.

The workflow checks out the release tag and publishes that exact version to the latest dist-tag.

Bleeding edge (next)

Triggered manually via workflow_dispatch. The workflow checks out the selected branch (usually master), appends -dev.<git-sha> to the version in package.json (e.g. 0.2.0-dev.a1b2c3d), and publishes to the next dist-tag without modifying git.

Install the bleeding edge build in a consumer project:

npm install --save-dev @wpsyntex/e2e-test-utils@next

Stable installs (npm install @wpsyntex/e2e-test-utils) are unaffected.