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

David Carr

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

 

Fathom Analytics $10 discount on your first invoice using this link

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

Sponsor

Fathom Analytics $10 discount on your first invoice using this link

Subscribe to my newsletter

Subscribe and get my books and product announcements.

© 2006 - 2024 DC Blog. All code MIT license. All rights reserved.