Files
wp-plugin-starter-template-…/.wiki/Playground-Testing.md

2.1 KiB

WordPress Playground Testing

This document explains how to use WordPress Playground for testing our plugin.

What is WordPress Playground?

WordPress Playground is a project that runs WordPress entirely in the browser using WebAssembly. This means:

  • No server required - WordPress runs in the browser
  • Fast startup times
  • Isolated testing environment
  • Works well with CI/CD pipelines

Setting Up WordPress Playground Locally

  1. Install the WordPress Playground CLI:
npm install -g @wordpress/playground-tools
  1. Start WordPress Playground with our blueprint:
wp-playground start --blueprint playground/blueprint.json --port 8888
  1. Open your browser and navigate to http://localhost:8888

Running Tests with WordPress Playground

We have two blueprints for testing:

  1. playground/blueprint.json - For single site testing
  2. playground/multisite-blueprint.json - For multisite testing

To run tests with WordPress Playground:

  1. Start WordPress Playground with the appropriate blueprint:
# For single site testing
wp-playground start --blueprint playground/blueprint.json --port 8888

# For multisite testing
wp-playground start --blueprint playground/multisite-blueprint.json --port 8888
  1. Run Cypress tests against WordPress Playground:
# For single site testing
npm run test:single:headless

# For multisite testing
npm run test:multisite:headless

Customizing Blueprints

You can customize the blueprints to suit your testing needs. See the WordPress Playground Blueprints documentation for more information.

CI/CD Integration

We have a GitHub Actions workflow that uses WordPress Playground for testing. See .github/workflows/playground-tests.yml for more information.

Performance Testing

We also use the WP Performance Tests GitHub Action for performance testing. This action tests our plugin against various WordPress versions and PHP versions to ensure it performs well in different environments.