It looks like the assets are not being loaded because the requests to http://tims.local are being refused. This is likely because the domain tims.local is not accessible within the Docker network created by Laravel Sail. Here are a few steps to troubleshoot and resolve the issue:
-
Ensure
tims.localis Resolvable: Make sure thattims.localis mapped to the correct IP address in your/etc/hostsfile on your host machine. It should point to127.0.0.1which is the loopback address.127.0.0.1 tims.local -
Use Service Name in Docker Network: Within the Docker network, services can communicate with each other using their service names defined in the
docker-compose.ymlfile. In your case, the service name for the Laravel application islaravel.test. So, you should configure your application to usehttp://laravel.testinstead ofhttp://tims.localwhen running Dusk tests. -
Update Dusk's
.envConfiguration: If you have a separate.env.dusk.localfile for Dusk testing, make sure that theAPP_URLis set to the service name with the correct port, like so:APP_URL=http://laravel.test:80If you don't have a separate environment file for Dusk, you can set this in your
.envfile when running tests. -
Update Asset URLs: Ensure that the asset URLs in your views/templates are using the correct base URL. If you're using Laravel Mix, you can use the
mixfunction to generate URLs for your assets, which will automatically use theAPP_URLfrom your.envfile.<link rel="stylesheet" href="{{ mix('css/app.css') }}"> <script src="{{ mix('js/app.js') }}"></script> -
Check Network Access: Verify that the Selenium service can access the
laravel.testservice. Since they are both in the same network (sail), they should be able to communicate without any issues. -
Clear Configuration Cache: Sometimes, configuration caching can cause issues. Make sure to clear the configuration cache by running:
php artisan config:clear -
Restart Docker Containers: After making changes to the
docker-compose.ymlfile or.envfile, you should restart your Docker containers to apply the changes:./vendor/bin/sail down ./vendor/bin/sail up -d -
Run Dusk Tests Again: After making the above changes, try running your Dusk tests again to see if the assets are now loading correctly.
If you follow these steps and ensure that your application and testing environment are configured to communicate within the Docker network, you should be able to load assets during your Dusk tests.