1

For debugging purpose, I would like to have Telescope record any requests coming from Testing suite. Telescope does not at the moment and I have no ideas why.

I enabled telescope in phpunit.xml

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

This is my Feature Test

$this->getJson('/api/vehicle')->assertStatus(401);

When I opened the Telescope, there is no entry for /api/vehicle saved.

Michael Nguyen
  • 1,691
  • 2
  • 18
  • 33
  • https://dyrynda.com.au/blog/using-laravel-telescope-in-specific-environments maybe this is what you looking for ? – Ahmed Aboud May 16 '19 at 00:39
  • the link tells me how to not include Telescope in build and testing env. By default, Telescope should work in any environment and it is where I stand at the moment. – Michael Nguyen May 16 '19 at 15:28

1 Answers1

2

I need to always force Telescope to record in TelescopeServiceProvider

class TelescopeServiceProvider extends TelescopeApplicationServiceProvider
{
    /**
     * Register any application services.
     *
     * @return void
     */
    public function register()
    {
        // Telescope::night();

        Telescope::filter(function (IncomingEntry $entry) {
            if ($this->app->environment('local')) {
                return true;
            }

            if ($this->app->environment('testing')) {
                return true;
            }

            return $entry->isReportableException() ||
                   $entry->isFailedJob() ||
                   $entry->isScheduledTask() ||
                   $entry->hasMonitoredTag();
        });
    }

And since the telescope frontend is linked to development-database, the telescope entries recorded during testing are saved in testing-database, that explain when I refresh the Telescope front-end (which use development-database), nothing was shown.

Michael Nguyen
  • 1,691
  • 2
  • 18
  • 33