Pest Testing Framework

Write Pest tests for Craft CMS routes, templates, and form submissions.

20|8|Updated Jul 14, 2023
One-click install
npx skills add https://github.com/markhuot/craft-pest-core --skill pest-testing-framework
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: Pest Testing Framework
Source: https://github.com/markhuot/craft-pest-core/tree/main/llms
Command: npx skills add https://github.com/markhuot/craft-pest-core --skill pest-testing-framework

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This skill removes the friction of setting up and writing tests for Craft CMS projects, eliminating boilerplate configuration and letting developers focus on testing custom application logic instead of fighting testing framework setup.

Core Features & Use Cases

  • Expressive Test Syntax: Write clean, readable tests for Craft CMS routes, Twig templates, entries, and form submissions using Pest's intuitive, chainable API instead of verbose PHPUnit code.
  • Craft-Specific Helpers: Access pre-built factories for entries, assets, users, and other Craft elements, plus built-in methods for simulating HTTP requests, rendering templates directly, and making DOM assertions.
  • Use Case: A Craft CMS developer can quickly write a test to verify a blog entry's title renders correctly on its single entry template, or that a contact form submission returns the expected validation error, without writing repetitive setup code.

Quick Start

Use this skill to write a Pest test that verifies your Craft CMS homepage loads successfully and displays the expected welcome heading.

Frequently Asked Questions about Pest Testing Framework

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I write tests for Craft CMS routes and Twig templates without boilerplate?

You can test Craft CMS routes and Twig templates without boilerplate by using Pest's expressive assertion and request simulation APIs to reduce setup time and improve test readability.

What is the best way to set up test factories for Craft CMS entries and users?

The best way to set up test factories for Craft CMS entries and users is using pre-built factory helpers that eliminate repetitive configuration overhead for your application's custom business logic.

Can I simulate HTTP requests and form submissions when testing a Craft CMS application?

Yes, you can simulate HTTP requests and form submissions when testing a Craft CMS application using built-in HTTP testing helpers to verify validation errors and route responses.

Do I need a specific PHP testing framework to test Craft CMS custom logic?

You need Pest PHP installed in your Craft CMS project to utilize this testing approach, which provides intuitive chainable methods instead of verbose PHPUnit code for testing application logic.

How do I verify a Twig template renders the correct entry data in Craft CMS?

You verify a Twig template renders the correct entry data in Craft CMS by applying built-in template rendering methods and DOM assertions directly within your Pest test cases.

Does this testing approach work for existing Craft CMS projects with complex custom logic?

This testing approach works for existing Craft CMS projects by letting developers focus on testing custom application logic directly rather than fighting testing framework setup and configuration overhead.