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 🙏

© 2025 – Pkg Stats / Ryan Hefner

wp-playwright

v1.0.0

Published

An e2e testing tool with playwright within WordPress to swap your environment easily.

Downloads

4

Readme

WP Playwright

Introduction

WP Playwright is an End-To-End (E2E) testing tool that leverages the power of Playwright to make it easier to test WordPress applications. With WP Playwright, you can quickly swap between different testing environments, allowing you to test your application in multiple configurations with ease.

Prerequisites:

Must have WP CLI installed.

Features

  • Easy setup: WP Playwright is designed to be easy to set up and start using.
  • Multiple environment support: With WP Playwright, you can quickly switch between development and testing environments, making it easier to test your application in different configurations.
  • Robust testing: Playwright is a robust testing tool that provides a variety of testing capabilities, including support for headless and non-headless browsers, automatic waiting for elements to load, and more.

Installation

To install WP Playwright, simply run the following command in your terminal:

npm install wp-playwright --save-dev

Usage

To get started with WP Playwright, simply import the library into your testing script and configure it to use the environment you want to test against.

Here's a basic example of how you might use WP Playwright in your projects:

Copy your wp-config.php file and place it in your plugin root directory like akismet/ and rename it with playwright-wp-config.php.

Add these line in playwright-wp-config.php if already not exists.

define( 'DB_NAME', 'change_it_to_test_db_name' );
define( 'DB_USER', 'root' );
define( 'DB_PASSWORD', '' );
define( 'DB_HOST', 'localhost' );

define( 'SITE_URL', 'your_site_url' ); // Like- https://test-wp.test
define( 'SITE_TITLE', 'Site_Name' ); // Like- Test WP Site
define( 'ADMIN_USERNAME', 'UserName' ); // This is not database username. This is login user name.
define( 'ADMIN_PASSWORD', 'Password' ); // This is not database password. This is login password.
define( 'ADMIN_EMAIL', '[email protected]' );

Add these lines in playwright.config.js file within the config section.

globalSetup: require.resolve( './global-setup' ),
globalTeardown: require.resolve( './global-teardown' ),

Now create global-setup.js and global-teardown.js in your plugin root directory.

Then, write like this example in global-setup.js,

import { join } from 'path'
const { swapEnvironment } = require('wp-playwright/swapEnvironment');

const wpConfigPath = join(__dirname, '..', '..', '..', 'wp-config.php'); // your wp-congig.php path
const wpTestsConfigPath = join(__dirname, 'playwright-wp-config.php'); // your wp-congig.php path

async function globalSetup() {
  await swapEnvironment(wpConfigPath, wpTestsConfigPath);
  
  // ..... add rest of your globalSetup code here
  
}

export default globalSetup;

Then, write like this example in global-teardown.js,

import { join } from 'path'
const { swapBackEnvironment } = require('wp-playwright/swapBackEnvironment');

const wpConfigPath = join(__dirname, '..', '..', '..', 'wp-config.php');
const wpTestsConfigPath = join(__dirname, 'playwright-wp-config.php');

async function globalTeardown() {
  await swapBackEnvironment(wpConfigPath, wpTestsConfigPath);
  
  // ..... add rest of your globalTeardown code here
  
}

export default globalTeardown;

This swapEnvironment.js file offers you some methods like-

  • swapEnvironment(wpConfigPath, wpTestsConfigPath) - This will swap your environment.
  • createDatabaseIfNotExists() - This will create your test database.
  • dropDatabaseTables() - This will reset your test database.
  • installWP(site_url, title, username, email, password) - This will refresh your WordPress installation.
  • renameFile(src, dest) - This will rename file.
  • readWpConfigFile(wpConfigPath) - This will read wp-config file and gives you defined values.

Documentation

For more information on how to use WP Playwright, including detailed instructions on how to configure different testing environments, check out the official documentation.

Contributing

If you're interested in contributing to the development of WP Playwright, we welcome your contributions! Simply fork the repository on Github, make your changes, and submit a pull request.

License

WP Playwright is open-source software licensed under the MIT License.

If this package helps you anyway, please give me a Star ⭐ on Github.

That's it, enjoy 🎉.

Have a query? Email me