Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Pest Plugin Profanity Laravel Package

pestphp/pest-plugin-profanity

Pest Profanity plugin helps enforce clean language in your test suite by detecting and preventing profanity in test names and output. Simple to install and use with Pest to keep your codebase and CI logs professional.

View on GitHub
Deep Wiki
Context7

Getting Started

Install the plugin via Composer:

composer require --dev pest/pest-plugin-profanity

Then run pest --init (if not already done) to register the plugin in your test suite. The plugin adds two new expectations:

  • assertNot profane() — assert a string does not contain profanity
  • assert profane() — assert a string does contain profanity

First use case: protect user-generated content (e.g., comments, reviews) from offensive language by asserting in your feature tests:

it('rejects comments with profanity', function () {
    expect($comment->body)->assertNot profane();
});

Implementation Patterns

  • Default behavior: checks for English profanity. To test multilingual apps, configure languages explicitly (see Gotchas).
  • Inline expectations: use within expect() for clarity and better error messages:
    expect($email->subject)->assertNot profane();
    expect($chat->message)->toNotBeProfane(); // alias
    
  • Custom tolerance lists: add context-aware false positives to the tolerated list in config/profanity.php (generated on first run). This avoids test flakiness around words like “ass” in “donkey” or “punt”.
  • Language-specific checks: enable multiple languages to catch regional variants:
    // phpunit.xml or config/profanity.php
    'languages' => ['en', 'pt_BR', 'es'],
    

Gotchas and Tips

  • False positives: the plugin flags words as profane even if embedded in otherwise safe text (e.g., “anal” vs “analysis”). Always extend the tolerated list with context-specific exceptions. Check the error output — v3.6.0+ reports the exact found words.
  • Case sensitivity: the plugin is case-insensitive by default, but watch for obfuscation (e.g., “a$$”, “b!tch”). Current version does not handle obfuscation out-of-the-box; consider preprocessing with a normalization strategy if needed.
  • Configuration: run php artisan vendor:publish --provider="Pest\Profanity\ProfanityServiceProvider" (Laravel) or manually copy config/profanity.php to your project to customize languages/tolerated words.
  • Performance: the profanity check is O(n) over the word list; for large inputs or many tests, prefer targeted assertions on key fields (e.g., title, body) rather than entire payloads.
  • Extensions: since it’s built on profanify, the underlying library is locale-aware — new languages are frequently added (Dutch, Danish, Arabic, Japanese, Russian, etc.), so keep composer.lock synced and check config/profanity.php for available language keys.
  • Debugging tip: use dd($text) alongside expect($text)->toBeProfane() during test development to quickly validate whether expected profanity is detected as intended.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
milesj/emojibase
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport