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.
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 profanityassert profane() — assert a string does contain profanityFirst 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();
});
expect() for clarity and better error messages:
expect($email->subject)->assertNot profane();
expect($chat->message)->toNotBeProfane(); // alias
tolerated list in config/profanity.php (generated on first run). This avoids test flakiness around words like “ass” in “donkey” or “punt”.// phpunit.xml or config/profanity.php
'languages' => ['en', 'pt_BR', 'es'],
tolerated list with context-specific exceptions. Check the error output — v3.6.0+ reports the exact found words.php artisan vendor:publish --provider="Pest\Profanity\ProfanityServiceProvider" (Laravel) or manually copy config/profanity.php to your project to customize languages/tolerated words.title, body) rather than entire payloads.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.dd($text) alongside expect($text)->toBeProfane() during test development to quickly validate whether expected profanity is detected as intended.How can I help you explore Laravel packages today?