From 47dae8723529a0cc2f2f91300d585f1b3383a72e Mon Sep 17 00:00:00 2001 From: Willem Leuverink Date: Tue, 20 Feb 2024 13:49:55 +0100 Subject: [PATCH] disable browser caching in dusk tests --- docs/advanced-usage.md | 3 +-- tests/DuskTestCase.php | 3 +++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/docs/advanced-usage.md b/docs/advanced-usage.md index b344341..5fdd917 100644 --- a/docs/advanced-usage.md +++ b/docs/advanced-usage.md @@ -101,7 +101,7 @@ Sourcemaps will be generated in a separate file so this won't affect performance {: .note } -> If your project stored previously bundled files you need to run the [bundle:clear](https://laravel-bundle.dev/advanced-usage.html#artisan-bundleclear) command +> If your project stored previously bundled files you need to run the [bundle:clear](https://laravel-bundle.dev/advanced-usage.html#artisan-bundleclear) command after enabling/disabling this feature. ## Cache-Control headers @@ -148,4 +148,3 @@ BundleManager::fake(); ``` When you'd like to use Dusk for browser testing you need to run Bundle in order for your tests not to blow up. Simply don't fake the BundleManager in your DuskTestCase. - diff --git a/tests/DuskTestCase.php b/tests/DuskTestCase.php index d1fde43..3400bfb 100644 --- a/tests/DuskTestCase.php +++ b/tests/DuskTestCase.php @@ -63,6 +63,8 @@ public function blade(string $blade) // Create a temporary route $this->beforeServingApplication(function ($app, $config) use ($page) { $config->set('app.debug', true); + $config->set('bundle.cache_control_headers', 'no-cache, no-store, must-revalidate'); + $app->make(Route::class)::get('test-blade', fn () => $page); }); @@ -87,6 +89,7 @@ public function serveLivewire($component) $this->beforeServingApplication(function ($app, $config) use (&$component) { $config->set('app.debug', true); $config->set('app.key', 'base64:q1fQla64BmAKJBOnRKuXvfddVoqEuSLv1eOEEO91uGI='); + $config->set('bundle.cache_control_headers', 'no-cache, no-store, must-revalidate'); // Needs to register so component is findable in update calls Livewire::component($component);