PHPackages                             ralfhortt/wp-vrt - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Testing &amp; Quality](/categories/testing)
4. /
5. ralfhortt/wp-vrt

ActiveWordpress-plugin[Testing &amp; Quality](/categories/testing)

ralfhortt/wp-vrt
================

WP VRT testing support

061↓33.3%PHP

Since Mar 13Pushed 3mo agoCompare

[ Source](https://github.com/Horttcore/wp-vrt)[ Packagist](https://packagist.org/packages/ralfhortt/wp-vrt)[ RSS](/packages/ralfhortt-wp-vrt/feed)WikiDiscussions main Synced 3w ago

READMEChangelogDependenciesVersions (1)Used By (0)

WP VRT
======

[](#wp-vrt)

Virtual pages for block/theme visual regression testing in WordPress.

Usage
-----

[](#usage)

- Block example: `/wp-vrt/block/core-paragraph`
- Block variation: `/wp-vrt/block/core-button/outline`
- Pattern: `/wp-vrt/pattern/{pattern-slug}`
- Template: `/wp-vrt/template/{template-slug}`
- Template part: `/wp-vrt/template-part/{part-slug}`
- Scenario: `/wp-vrt/scenario/{scenario-slug}`

Discovery Endpoint
------------------

[](#discovery-endpoint)

`/wp-json/wp-vrt/v1/discover`

Returns a manifest of blocks, patterns, templates, template parts, and scenarios with URLs.

Pest Visual Regression
----------------------

[](#pest-visual-regression)

Install dev dependencies:

```
composer install
```

Install Playwright for screenshots:

```
npm install -D playwright
```

Admin UI Build
--------------

[](#admin-ui-build)

Install dependencies and build the admin UI bundle:

```
npm install
npm run build
```

For development:

```
npm run start
```

Run tests:

```
WP_VRT_BASE_URL="http://bedrock.test" composer test
```

You can override the Node binary:

```
NODE_BINARY="/usr/local/bin/node" composer test
```

To store screenshot PNGs in `wp-content/wp-vrt-snapshots`, set:

```
WP_VRT_SNAPSHOT_DIR="/path/to/wp-content/wp-vrt-snapshots" composer test
```

Scenarios (theme/plugin)
------------------------

[](#scenarios-themeplugin)

Register custom scenarios from your theme or another plugin.

```
add_filter('wp_vrt_register_scenarios', function ($scenarios) {
    $scenarios['button-states'] = [
        'title' => 'Button - All States',
        'description' => 'Default and outline buttons',
        'content' => '

                Default

                Outline

        ',
    ];

    return $scenarios;
});
```

You can also use a callable for `content` if you need custom logic.

Default Scenario Coverage
-------------------------

[](#default-scenario-coverage)

WP VRT does not ship any built-in scenarios. Scenarios are expected to be registered by your theme or other plugins.

ScenarioCoverageNotes(none)N/ARegister scenarios via `wp_vrt_register_scenarios`Block Discovery Filters
-----------------------

[](#block-discovery-filters)

By default, WP VRT includes all registered blocks. You can narrow it down:

```
// Only include these blocks
add_filter('wp_vrt_block_allowlist', function () {
    return ['core/paragraph', 'core/heading', 'acf/hero'];
});

// Or exclude specific blocks
add_filter('wp_vrt_block_denylist', function () {
    return ['core/legacy-widget', 'plugin/experimental-block'];
});
```

### Excluded Blocks

[](#excluded-blocks)

By default, WP VRT excludes the following blocks from discovery:

BlockReason`core/social-link-*` (39 variants)Consolidated into single `core/social-links` block with all 39 social platforms as children`core/template-part`Cannot be meaningfully previewed without template context`core/pattern`Cannot be meaningfully previewed without theme context`core/widget-group`Requires legacy widget contextThis results in 87 discoverable blocks instead of 129, with all blocks having meaningful sample content.

Enable/Disable Exposed Items
----------------------------

[](#enabledisable-exposed-items)

You can disable items from being exposed by default. Disabled items are hidden unless you enable the flag.

```
add_filter('wp_vrt_is_item_enabled', function ($enabled, $type, $id, $item) {
    if ($type === 'block' && $id === 'core/paragraph') {
        return false;
    }
    return $enabled;
}, 10, 4);

add_filter('wp_vrt_template_part_enabled', function ($enabled, $template) {
    return $template->slug !== 'header';
}, 10, 2);
```

Show disabled items:

- Admin UI: toggle on `Tools → WP VRT`
- Discovery: `/wp-json/wp-vrt/v1/discover?include_disabled=1`

To toggle items from the UI, use the disable/enable icon on each row.

Block Families
--------------

[](#block-families)

The admin UI groups blocks that are commonly used together. You can add or override families:

```
add_filter('wp_vrt_block_families', function ($families) {
    $families[] = [
        'title' => 'Accordion',
        'description' => 'Accordion with item blocks.',
        'blocks' => ['my/accordion', 'my/accordion-item'],
    ];
    return $families;
});
```

Block Sample Content
--------------------

[](#block-sample-content)

Dynamic blocks render from attributes only. Static blocks still require inner markup for rendering on the frontend, so WP VRT provides minimal HTML for core blocks. You can override per block:

```
add_filter('wp_vrt_block_content', function ($content, $block_name) {
    if ($block_name === 'core/paragraph') {
        return [[
            'attrs' => ['content' => 'Custom paragraph text'],
            'content' => 'Custom paragraph text',
        ]];
    }
    return $content;
}, 10, 2);
```

WP-CLI Snapshots
----------------

[](#wp-cli-snapshots)

Generate PNG snapshots into `wp-content/wp-vrt-snapshots`:

```
wp vrt snapshots --types=blocks --width=1200 --height=800
```

Options:

- `--types=blocks,patterns,templates,parts,scenarios`
- `--base-url=https://example.test`
- `--dir=/path/to/wp-content/wp-vrt-snapshots`
- `--width=1200`
- `--height=800`
- `--node=/path/to/node`

WP-CLI Test
-----------

[](#wp-cli-test)

Generate snapshots and run Pest in one command:

```
wp vrt test --base-url="http://bedrock.test"
```

Dynamic Content
---------------

[](#dynamic-content)

Dynamic blocks that require post context (like query, post content, comments, etc.) are supported by providing a post context for rendering.

To provide a specific post ID for context:

```
add_filter('wp_vrt_dynamic_post_id', function () {
    return 123;
});
```

If no post ID is provided, WP VRT automatically:

1. Uses the first published post if one exists
2. Creates a temporary draft post and deletes it after rendering if no posts exist

###  Health Score

21

—

LowBetter than 18% of packages

Maintenance54

Moderate activity, may be stable

Popularity11

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity12

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/45d54752dcf3da868ffe4a5ad2b876d6acb911fd914700b52e4d4777ff7d4a02?d=identicon)[Ralf Hortt](/maintainers/Ralf%20Hortt)

---

Top Contributors

[![Horttcore](https://avatars.githubusercontent.com/u/503252?v=4)](https://github.com/Horttcore "Horttcore (5 commits)")

### Embed Badge

![Health badge](/badges/ralfhortt-wp-vrt/health.svg)

```
[![Health](https://phpackages.com/badges/ralfhortt-wp-vrt/health.svg)](https://phpackages.com/packages/ralfhortt-wp-vrt)
```

###  Alternatives

[dms/phpunit-arraysubset-asserts

This package provides ArraySubset and related asserts once deprecated in PHPUnit 8

14228.7M340](/packages/dms-phpunit-arraysubset-asserts)[orchestra/workbench

Workbench Companion for Laravel Packages Development

8219.1M69](/packages/orchestra-workbench)[phpbenchmark/phpbenchmark

Easy to use benchmark toolkit for your PHP-application. This library contains classes for comparing algorithms as well as benchmarking application responses

8011.5k2](/packages/phpbenchmark-phpbenchmark)[kunicmarko/graphql-test

GraphQL Test Cases

1359.0k](/packages/kunicmarko-graphql-test)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
