Open Fadarrizz opened 1 week ago
Are you able to share an example of a test that's running slow? What does your TestCase
look like?
Hi @duncanmcclean,
This is what my TestCase looks like:
<?php
declare(strict_types = 1);
namespace Tests;
use Nuwave\Lighthouse\Testing\MakesGraphQLRequests;
use Nuwave\Lighthouse\Testing\RefreshesSchemaCache;
use Illuminate\Foundation\Testing\TestCase as BaseTestCase;
abstract class TestCase extends BaseTestCase
{
use MakesGraphQLRequests;
use RefreshesSchemaCache;
/**
* Setup the test environment.
*
* @return void
*/
protected function setUp(): void
{
parent::setUp();
$this->withoutVite();
}
}
I use Pest btw:
<?php
declare(strict_types = 1);
use Illuminate\Foundation\Testing\RefreshDatabase;
uses(Tests\TestCase::class, RefreshDatabase::class)->in('Feature');
A test that runs slow for example is the following:
<?php
declare(strict_types = 1);
test('that the dd and dump functions are not used in the codebase')
->expect(['dd', 'dump'])
->not
->toBeUsed();
This test takes ~6.5 seconds to complete with Statamic installed. Without Statamic (by not letting Composer discover Statamic), the test takes ~5 seconds to complete.
Thanks!
What about tests that aren't 5 seconds long to begin with? That's already slow.
So, I trimmed some stuff down to have the bare minimum in feature tests:
// tests/TestCase.php
<?php
declare(strict_types = 1);
namespace Tests;
use Illuminate\Foundation\Testing\TestCase as BaseTestCase;
abstract class TestCase extends BaseTestCase
{
/**
* Setup the test environment.
*
* @return void
*/
protected function setUp(): void
{
parent::setUp();
$this->withoutVite();
}
}
// tests/Pest.php
<?php
declare(strict_types = 1);
uses(Tests\TestCase::class)->in('Feature');
I wrote the most basic test I could think of and ran it both with and without Statamic:
// tests/Feature/Test.php
<?php
declare(strict_types = 1);
test('true', function () {
expect(true)->toBe(true);
});
This test takes 0.42 sec on my machine without Statamic installed (this time I removed both Statamic packages from Composer).
With Statamic, this test takes 1.91 sec.
Do you have any idea what makes it run slower?
Bug description
After installing Statamic in an existing Laravel project, all non-Statamic tests take more than a second per test longer.
I've been playing with some config settings, such as stache, but nothing seems to improve it.
How to reproduce
Logs
No response
Environment
Installation
Existing Laravel app
Additional details
No response