Summer Sale! All accounts are 50% off this week.

datamonster's avatar

Laravel Dusk Testing - Old template files are shown

Hi,

I've customized registration process and now testing via Laravel dusk. It was working fine then suddenly my tests are failing and when i noticed the screenshots i came to know that it's showing old templates (blade) while I've made many changes in view files.

I've tried php artisan config:clear, php artisan cache:clear, php artisan route:cache and many more artisan commands to clear but none of them worked for me.

Any idea why this weired behaviour ?

0 likes
5 replies
tobiasj's avatar

Did you try composer dump autoload or artisan optimize (pretty sure it dumps the autoload too)?

Note: never tried dusk, just a wild guess.

eugenefvdm's avatar

Any luck? I just noticed that Dusk is using cached pages. I'm using Linux with Valet, tried various cache clear commands but no luck.

ephraimlambarte's avatar

im using laravel 11 with inertia and vue. i am also experiencing this

ajaypatel9016's avatar

It sounds like Laravel Dusk may be caching your old views, which can happen due to browser caching or due to stale compiled views. Here are a few steps you can try to resolve this:

  1. Clear Compiled Views:

    • Run php artisan view:clear to clear any compiled view files. This should ensure that Laravel re-compiles all blade files.
  2. Clear Laravel Dusk's Browser Cache:

    • Laravel Dusk runs tests in a browser (like Chrome), which can cache pages. Try running:
      php artisan dusk:chrome --no-sandbox --disable-application-cache --incognito
      
    • You can add other flags like --disable-cache or --disable-gpu if needed.
  3. Delete the Cached Files Manually:

    • Sometimes, cached files don’t clear properly. Try deleting the contents in bootstrap/cache (but keep the .gitignore file if you're using Git).
  4. Restart the Dusk Test Process:

    • Close all running Dusk instances and restart the test process after clearing the cache to ensure Dusk picks up the latest view files.
  5. Run in a Clean Environment:

    • If all else fails, try running Dusk in a clean environment by restarting your server or using a separate testing environment to ensure there’s no conflicting cache.

After performing these steps, re-run your Dusk tests to check if the changes are now reflected.

I hope this helps..!!

Please or to participate in this conversation.