Skip to content

Conversation

@bgrgicak
Copy link
Owner

@bgrgicak bgrgicak commented Oct 31, 2025

Motivation for the change, related issues

The previous testing infrastructure only supported basic boot tests. This refactor introduces Vitest as the test framework, enabling us to write comprehensive integration tests for WordPress plugins and themes.

Implementation details

Test Framework:

  • Uses Vitest to run WordPress integration tests via @wp-playground/cli
  • Test file: src/test/unit/wordpress.spec.ts - validates boot, post creation, wp-admin loading, plugin/theme activation
  • Configuration: vitest.config.ts with 2-minute timeouts for WordPress installation
  • src/test-runner.ts spawns vitest with mode-specific Node.js flags
    • Asyncify mode: Default Node.js (stable)
    • JSPI mode: Node.js with --experimental-wasm-jspi flag
  • Both modes run in parallel for each plugin/theme

Error Parser (src/lib/log-parser.ts):

  • Extracts errors from vitest results.json and error.log files
  • Categorizes: PHP errors (Fatal/Warning/Notice/etc.), SQL errors, Playground runtime errors
  • Deduplicates and outputs structured error.json

Testing instructions

Run unit tests:

npm test

Test single item:

npm run test:batch -- --plugins --dry-run --item-path=data/logs/plugins/a/akismet

Test a batch:

npm run test:batch -- --plugins --limit=10 --dry-run

Expected output:

Testing akismet
✅ akismet (asyncify) passed
✅ akismet (jspi) passed
Screenshot 2025-11-04 at 14 44 45

TODO

  • Remove unused .sh files
  • Implement PR tests

@bgrgicak bgrgicak self-assigned this Oct 31, 2025
- Run Asyncify and JSPI modes simultaneously instead of sequentially
- Smart port allocation: Asyncify uses workerId, JSPI uses workerId + MAX_CONCURRENCY
- Reduces test time per item from ~4min to ~2min (~50% improvement)
- Configurable via single MAX_CONCURRENCY constant (default: 8)
- Supports MAX_CONCURRENCY × 2 concurrent Playground instances
- No port conflicts, scales automatically with concurrency setting
@bgrgicak bgrgicak changed the title User runCLI to test plugins and themes User runCLI and unit tests to test plugins and themes Nov 5, 2025
@bgrgicak bgrgicak requested a review from Copilot November 5, 2025 10:47
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR refactors the testing infrastructure to use Vitest and @wp-playground/cli for comprehensive integration tests of WordPress plugins and themes. Previously only basic boot tests were supported; now the system can validate WordPress boot, post creation, wp-admin loading, and plugin/theme activation.

Key Changes:

  • Introduced Vitest-based test framework with wordpress.spec.ts integration tests
  • Implemented dual-mode testing (Asyncify and JSPI) that runs in parallel for each item
  • Added error log parser to extract and categorize PHP, SQL, and Playground runtime errors

Reviewed Changes

Copilot reviewed 8 out of 10 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
vitest.config.ts Configures Vitest with 2-minute timeouts and exclusion patterns
src/test/unit/wordpress.spec.ts Core integration tests for WordPress boot, post creation, wp-admin, and plugin/theme activation
src/test-runner.ts Spawns Vitest with mode-specific Node.js flags (JSPI vs Asyncify)
src/test-batch.ts Orchestrates batch testing with concurrency control and aggregates results from both modes
src/lib/log-parser.ts Parses error logs and test results to generate structured error reports
package.json Updates dependencies to support new testing framework

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

The wordpress-develop directory was registered as a submodule in Git's
index but not in .gitmodules, causing CI failures when trying to
initialize submodules. This directory is not used by the playground
compatibility tester and is excluded from tests.

Fixes CI error: fatal: No url found for submodule path 'wordpress-develop' in .gitmodules

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
@bgrgicak bgrgicak requested a review from Copilot November 5, 2025 10:56
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 7 out of 9 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@bgrgicak bgrgicak marked this pull request as ready for review November 6, 2025 07:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants