Skip to content

Commit

Permalink
disable browser caching in dusk tests
Browse files Browse the repository at this point in the history
  • Loading branch information
gwleuverink committed Feb 20, 2024
1 parent 44fbe4c commit 47dae87
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 1 addition & 2 deletions docs/advanced-usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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.

3 changes: 3 additions & 0 deletions tests/DuskTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});

Expand All @@ -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);
Expand Down

0 comments on commit 47dae87

Please sign in to comment.