Laravel Telescope error when running tests ReflectionException: Class env does not exist

David Carr

Laravel Telescope error when running tests ReflectionException: Class env does not exist

Development

Today I came across an error in a Laravel application that runs Telescope that when I run PHPUnit I was getting this error:

1) Tests\Unit\ExampleTest::testBasicTest
ReflectionException: Class env does not exist

The solution to fix this is to open phpunit.xml and add the below line in the php section.

<env name="TELESCOPE_ENABLED" value="false"/>

This disables Telescope and allows your test suite to run.

Remember to clear the cache afterwards:

php artisan clear
php artisan config:clear

 

Laravel Modules Book by David Carr

Help support the blog so that I can continue creating new content!

Subscribe to my newsletter

Subscribe and get my books and product announcements.

© 2009 - 2022 DC Blog. All code MIT license. All rights reserved.