This package is abandoned and no longer maintained. No replacement package was suggested.

Prevent unwanted output in tests.

v0.1.2 2022-02-22 15:04 UTC

This package is auto-updated.

Last update: 2023-11-04 14:44:48 UTC


This repository has been archived and is no longer maintained.

Pest Plugin Silence

Tests PHPStan

Often, when writing tests, we echo and dump test code to debug and check everything is working correctly. It can be easy to forget to remove those statements when you've finished, which can lead to a lot of messy output in your test results. Yuk!

Silence is a lightweight plugin for Pest that will cause any test that echos or dumps to the console to fail, meaning that you'll never forget to remove those statements from your codebase.


CleanShot 2022-02-22 at 14 51 15@2x


CleanShot 2022-02-22 at 14 53 35@2x


Install the plugin via composer.

composer require worksome/pest-plugin-silence --dev 


Silence isn't enabled out of the box. However, it's simple to enable it for your project using one of two methods.

Enable with an environment variable

You can enable Silence using the PREVENT_OUTPUT environment variable whilst running your tests. You may add this to your phpunit.xml.

        <env name="PREVENT_OUTPUT" value="true"/>

Enable manually in your test or TestCase

Alternatively, for a more selective approach, you may enable Silence in your test or TestCase using the Silence::preventOutput() method.

use Worksome\PestPluginSilence\Silence;

it('just works', function () {
    echo "Uh-oh!"

If you want to manually enable Silence for every test, place it in the setUp method of your TestCase.

class TestCase extends BaseTestCase
    public function setUp(): void


Silence is fully tested, and also implements strict static analysis. You can run the test suite using our test script:

composer test


Please see CHANGELOG for more information on what has changed recently.



The MIT License (MIT). Please see License File for more information.