<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Georgi Kurian</title>
    <description>The latest articles on DEV Community by Georgi Kurian (@georgykurian).</description>
    <link>https://dev.to/georgykurian</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F538805%2F041b7a0b-78fa-4782-95a2-4f3eec9c6f48.png</url>
      <title>DEV Community: Georgi Kurian</title>
      <link>https://dev.to/georgykurian</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/georgykurian"/>
    <language>en</language>
    <item>
      <title>How to set up Laravel Dusk on Laravel Sail or docker.</title>
      <dc:creator>Georgi Kurian</dc:creator>
      <pubDate>Sun, 29 Aug 2021 08:37:01 +0000</pubDate>
      <link>https://dev.to/georgykurian/how-to-run-laravel-dusk-on-laravel-sail-docker-with-a-custom-database-3olk</link>
      <guid>https://dev.to/georgykurian/how-to-run-laravel-dusk-on-laravel-sail-docker-with-a-custom-database-3olk</guid>
      <description>&lt;p&gt;Yesterday, I was trying to step up Laravel Dusk to test our Laravel web app to make sure that the pages are not crashing for a Vue frontend using Inertia for our releases. But, I ran into many problems, and it took way more time than I expected to set up in Sail. I am posting this so that it could help someone else.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;I am using alias &lt;code&gt;sail&lt;/code&gt; as alias for &lt;code&gt;./vendor/bin/sail&lt;/code&gt; throughout&lt;/em&gt;.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;First, install Laravel Dusk.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="go"&gt;sail composer require --dev laravel/dusk
sail php artisan dusk:install
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We are going to customize the Laravel Sail default docker configuration, so publish the Sail docker file.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;sail artisan sail:publish
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Sail's default &lt;code&gt;mysql&lt;/code&gt; service persists the MySQL data to the local machine so that it is available after restarting the container. This is not needed for a test database, so we are going to create a new MySQL service named &lt;code&gt;mysql.test&lt;/code&gt; for testing purposes. Since we have are going to use two both Laravel Test(Phpunit) and Laravel Dusk in our app we need two separate databases for each one. Dusk will use the database &lt;code&gt;dusk_test&lt;/code&gt; and Phpunit will take &lt;code&gt;laravel_test&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;By default, Dusk will take the database connection specified &lt;code&gt;.env&lt;/code&gt; file. Since we don't want Dusk to change our data in the development database, we are going to specify a different database for Dusk. Dusk has a feature that replaces the &lt;code&gt;.env&lt;/code&gt; file with &lt;code&gt;.env.dusk.{environment}&lt;/code&gt; when we run the tests. We will specify the Laravel Dusk test configuration in the &lt;code&gt;.env.dusk.local&lt;/code&gt; file as below.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight conf"&gt;&lt;code&gt;&lt;span class="n"&gt;APP_NAME&lt;/span&gt;=&lt;span class="n"&gt;Laravel&lt;/span&gt;
&lt;span class="n"&gt;APP_ENV&lt;/span&gt;=&lt;span class="n"&gt;local&lt;/span&gt;
&lt;span class="n"&gt;APP_KEY&lt;/span&gt;=&lt;span class="n"&gt;base64&lt;/span&gt;:&lt;span class="n"&gt;EUzC7XceXTxeQwT&lt;/span&gt;+&lt;span class="n"&gt;eRMEysZwrs6e&lt;/span&gt;/&lt;span class="n"&gt;pHjO2xYUNZTggo&lt;/span&gt;=
&lt;span class="n"&gt;APP_DEBUG&lt;/span&gt;=&lt;span class="n"&gt;true&lt;/span&gt;
&lt;span class="n"&gt;APP_URL&lt;/span&gt;=&lt;span class="n"&gt;http&lt;/span&gt;://&lt;span class="n"&gt;laravel&lt;/span&gt;.&lt;span class="n"&gt;test&lt;/span&gt;

&lt;span class="n"&gt;LOG_CHANNEL&lt;/span&gt;=&lt;span class="n"&gt;stack&lt;/span&gt;
&lt;span class="n"&gt;LOG_LEVEL&lt;/span&gt;=&lt;span class="n"&gt;debug&lt;/span&gt;

&lt;span class="n"&gt;DB_CONNECTION&lt;/span&gt;=&lt;span class="n"&gt;mysql&lt;/span&gt;
&lt;span class="n"&gt;DB_HOST&lt;/span&gt;=&lt;span class="n"&gt;mysql&lt;/span&gt;.&lt;span class="n"&gt;test&lt;/span&gt;
&lt;span class="n"&gt;DB_DATABASE&lt;/span&gt;=&lt;span class="n"&gt;dusk_test&lt;/span&gt;
&lt;span class="n"&gt;DB_USERNAME&lt;/span&gt;=&lt;span class="n"&gt;sail&lt;/span&gt;
&lt;span class="n"&gt;DB_PASSWORD&lt;/span&gt;=&lt;span class="n"&gt;password&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The database for Dusk in the above is configured to use a different database port &lt;code&gt;3307&lt;/code&gt; as the port &lt;code&gt;3306&lt;/code&gt; is assigned to the &lt;code&gt;mysql&lt;/code&gt; service and we changed the database name to &lt;code&gt;dusk_test&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Now, we need the Sail to have the above-configured database service to be up and running for the tests to run. Add new service &lt;code&gt;mysql_test&lt;/code&gt; with the configuration below.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="s"&gt;mysql.test&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;image&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;mysql:8.0"&lt;/span&gt;
  &lt;span class="na"&gt;ports&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;${FORWARD_DB_PORT:-3307}:3306"&lt;/span&gt;
  &lt;span class="na"&gt;environment&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;MYSQL_ROOT_PASSWORD&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;${DB_PASSWORD}"&lt;/span&gt;
    &lt;span class="na"&gt;MYSQL_DATABASE&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;${DB_DATABASE}_test"&lt;/span&gt;
    &lt;span class="na"&gt;MYSQL_USER&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;${DB_USERNAME}"&lt;/span&gt;
    &lt;span class="na"&gt;MYSQL_PASSWORD&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;${DB_PASSWORD}"&lt;/span&gt;
    &lt;span class="na"&gt;MYSQL_ALLOW_EMPTY_PASSWORD&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;yes"&lt;/span&gt;
  &lt;span class="na"&gt;volumes&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;./docker/mysql.test/init:/docker-entrypoint-initdb.d"&lt;/span&gt;
  &lt;span class="na"&gt;tmpfs&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;/var/lib/mysql"&lt;/span&gt;
  &lt;span class="na"&gt;networks&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;sail&lt;/span&gt;
  &lt;span class="na"&gt;healthcheck&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;test&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="pi"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;CMD"&lt;/span&gt;&lt;span class="pi"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;mysqladmin"&lt;/span&gt;&lt;span class="pi"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;ping"&lt;/span&gt;&lt;span class="pi"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;-p${DB_PASSWORD}"&lt;/span&gt;&lt;span class="pi"&gt;]&lt;/span&gt;
    &lt;span class="na"&gt;retries&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;3&lt;/span&gt;
    &lt;span class="na"&gt;timeout&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;5s&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Important things in the above config:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;We have configured the default port to be &lt;code&gt;3307&lt;/code&gt; to not conflict with &lt;code&gt;mysql&lt;/code&gt; service.&lt;/li&gt;
&lt;li&gt;The database name is &lt;code&gt;${DB_DATAbase}_test&lt;/code&gt;. This database is going to be used by PHPUnit.&lt;/li&gt;
&lt;li&gt;Since &lt;code&gt;mysql&lt;/code&gt; docker image supports only one database in configuration, but we need two databases for tests, we are going to create a sql script in the path &lt;code&gt;./.docker/mysql.test/init/01-database.sql&lt;/code&gt; to create additional databases. This script will be copied to the container path &lt;code&gt;/docker-entrypoint-initdb.d&lt;/code&gt; and will be run during initialization.&lt;/li&gt;
&lt;li&gt;For volume, we are using a &lt;code&gt;tmpfs&lt;/code&gt; as the data don't have to be persisted.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The file &lt;code&gt;./docker/mysql.test/init/01-create_dusk_database.sql&lt;/code&gt; in the project should have the script:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="cm"&gt;/* create databases */&lt;/span&gt;
&lt;span class="k"&gt;CREATE&lt;/span&gt; &lt;span class="k"&gt;DATABASE&lt;/span&gt; &lt;span class="n"&gt;IF&lt;/span&gt; &lt;span class="k"&gt;NOT&lt;/span&gt; &lt;span class="k"&gt;EXISTS&lt;/span&gt; &lt;span class="nv"&gt;`dusk_test`&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="cm"&gt;/* give access to database */&lt;/span&gt;
&lt;span class="k"&gt;GRANT&lt;/span&gt; &lt;span class="k"&gt;ALL&lt;/span&gt; &lt;span class="k"&gt;PRIVILEGES&lt;/span&gt; &lt;span class="k"&gt;ON&lt;/span&gt; &lt;span class="n"&gt;dusk_test&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="k"&gt;TO&lt;/span&gt; &lt;span class="s1"&gt;'sail'&lt;/span&gt;&lt;span class="o"&gt;@&lt;/span&gt;&lt;span class="s1"&gt;'%'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Restart the sail by executing &lt;code&gt;sail up&lt;/code&gt; command. You can see that &lt;code&gt;mysql.test&lt;/code&gt; started and it has two databases &lt;code&gt;*_test&lt;/code&gt; and &lt;code&gt;dusk_test&lt;/code&gt; databases.&lt;/p&gt;

&lt;p&gt;Create a &lt;code&gt;.env.testing&lt;/code&gt; config file for specifying the PHPUnit test configuration. The database name will be the database name in your .env file and add &lt;code&gt;_test&lt;/code&gt; at the end. No need to give the&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight conf"&gt;&lt;code&gt;&lt;span class="n"&gt;APP_NAME&lt;/span&gt;=&lt;span class="n"&gt;Laravel&lt;/span&gt;
&lt;span class="n"&gt;APP_ENV&lt;/span&gt;=&lt;span class="n"&gt;local&lt;/span&gt;
&lt;span class="n"&gt;APP_KEY&lt;/span&gt;=&lt;span class="n"&gt;base64&lt;/span&gt;:&lt;span class="n"&gt;EUzC7XceXTxeQwT&lt;/span&gt;+&lt;span class="n"&gt;eRMEysZwrs6e&lt;/span&gt;/&lt;span class="n"&gt;pHjO2xYUNZTggo&lt;/span&gt;=
&lt;span class="n"&gt;APP_DEBUG&lt;/span&gt;=&lt;span class="n"&gt;true&lt;/span&gt;
&lt;span class="n"&gt;APP_URL&lt;/span&gt;=&lt;span class="n"&gt;http&lt;/span&gt;://&lt;span class="n"&gt;localhost&lt;/span&gt;

&lt;span class="n"&gt;LOG_CHANNEL&lt;/span&gt;=&lt;span class="n"&gt;stack&lt;/span&gt;
&lt;span class="n"&gt;LOG_LEVEL&lt;/span&gt;=&lt;span class="n"&gt;debug&lt;/span&gt;

&lt;span class="n"&gt;DB_CONNECTION&lt;/span&gt;=&lt;span class="n"&gt;mysql&lt;/span&gt;
&lt;span class="n"&gt;DB_HOST&lt;/span&gt;=&lt;span class="n"&gt;mysql&lt;/span&gt;.&lt;span class="n"&gt;test&lt;/span&gt;
&lt;span class="c"&gt;# Below database name should your database name in .env file and add `_test`
&lt;/span&gt;&lt;span class="n"&gt;DB_DATABASE&lt;/span&gt;=*&lt;span class="err"&gt;_&lt;/span&gt;&lt;span class="n"&gt;test&lt;/span&gt;
&lt;span class="n"&gt;DB_USERNAME&lt;/span&gt;=&lt;span class="n"&gt;sail&lt;/span&gt;
&lt;span class="n"&gt;DB_PASSWORD&lt;/span&gt;=&lt;span class="n"&gt;password&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now we have completed all the configurations. It's time to test now!&lt;br&gt;
Update the class in file &lt;code&gt;tests/Feature/ExampleTest.php&lt;/code&gt; with below:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;ExampleTest&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="nc"&gt;TestCase&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kn"&gt;use&lt;/span&gt; &lt;span class="nc"&gt;RefreshDatabase&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="n"&gt;test_example&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nc"&gt;User&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;factory&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;create&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
        &lt;span class="nv"&gt;$response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;$this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'/'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="nv"&gt;$response&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;assertStatus&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;200&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="nv"&gt;$this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;assertDatabaseCount&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'users'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Replace the function class in file &lt;code&gt;tests/Browser/ExampleTest.php&lt;/code&gt; with the below code&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;ExampleTest&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="nc"&gt;DuskTestCase&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kn"&gt;use&lt;/span&gt; &lt;span class="nc"&gt;DatabaseMigrations&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="n"&gt;testBasicExample&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nc"&gt;User&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;factory&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;create&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
        &lt;span class="nv"&gt;$this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;browse&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;Browser&lt;/span&gt; &lt;span class="nv"&gt;$browser&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="nv"&gt;$browser&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;visit&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'/'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;assertSee&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'Laravel'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="p"&gt;});&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Run both Phpunit and Dusk tests and see them both passing with database access.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;sail &lt;span class="nb"&gt;test&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Debugging Tips
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Check whether all the required services have started.&lt;/li&gt;
&lt;li&gt;Check whether our SQL script is copied into the container(&lt;code&gt;sail shell&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;Check database connections and the databases in it using a database client in your host machine.&lt;/li&gt;
&lt;li&gt;Check whether you can &lt;code&gt;curl http://laravel.test&lt;/code&gt; from inside your container &lt;code&gt;laravel.test&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Running &lt;code&gt;php artisan dusk&lt;/code&gt; from inside the container won't work by default as Sail is doing some additional things behind the scene (use &lt;code&gt;sail dusk&lt;/code&gt;).&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Additional information
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;If you add &lt;code&gt;DUSK_DRIVER_URL=http://selenium:4444/wd/hub&lt;/code&gt; to your &lt;code&gt;.env.dusk.local&lt;/code&gt; file you can run the dusk from inside the container using &lt;code&gt;php artisan dusk&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>laravel</category>
      <category>docker</category>
      <category>sail</category>
      <category>phpunit</category>
    </item>
  </channel>
</rss>
