title: Laravel Reset Database after Test
body: <p>I have just started using Laravel Dusk to test my project and need some guidance. After I run all the tests available, I want to be able to reset my database back to before I run the tests. (If there were any entries in my database before I run the tests, I would still like to see them after I run the tests. However, any entires created during the test, I would not like to see them after the tests finish running.) Any pointers on how I would achieve this? Thank you! </p>
  
  <p>Update:</p>
  
  <pre><code>&lt;?php
  
  namespace Tests\Browser;
  
  use Tests\DuskTestCase;
  use Laravel\Dusk\Browser;
  use Illuminate\Foundation\Testing\DatabaseTransactions;
  
  class UserRegisterTest extends DuskTestCase
  {
      use DatabaseTransactions;
      /**
       * A test for user registration.
       * @group register
       * @return void
       */
  
      public function testRegisterUser()
      {
          //Register with all info filled out correctly
          $this-&gt;browse(function ($browser){
              $browser-&gt;visit('/register')
                      -&gt;type('firstName', 'JenLogin')
                      -&gt;type('lastName', 'Zhou')
                      -&gt;type('email', 'testLogin@gmail.com')
                      -&gt;type('bio', 'Hello, this user is for testing login purposes!')
                      -&gt;type('location_zip', '11111')
                      -&gt;type('password', '123456')
                      -&gt;type('password_confirmation', '123456')
                      -&gt;click('.btn-primary')
                      -&gt;assertPathIs('/home')
                      -&gt;click('.dropdown-toggle')
                      -&gt;click('.dropdown-menu li:last-child');
  
          });
  
          $this-&gt;assertDatabaseHas('users', ['firstName' =&gt; 'JenLogin', 'lastName' =&gt; 'Zhou', 'email' =&gt; 'testLogin@gmail.com']);
  
  
      }
  
      /**
       * Register with duplicate user
       * @group register
       * @return void
       */
      public function testRegisterDuplicateUser(){
  
          $this-&gt;browse(function ($browser){
              $browser-&gt;visit('/register')
                  -&gt;type('firstName', 'JenLoginDup')
                  -&gt;type('lastName', 'Zhou')
                  -&gt;type('email', 'testLogin@gmail.com')
                  -&gt;type('bio', 'Hello, this user is for testing login purposes!')
                  -&gt;type('location_zip', '11111')
                  -&gt;type('password', '123456')
                  -&gt;type('password_confirmation', '123456')
                  -&gt;click('.btn-primary')
                  -&gt;assertPathIs('/register')
                  -&gt;assertSee('The email has already been taken.');
          });
  
          $this-&gt;assertDatabaseMissing('users', ['firstName' =&gt; 'JenLoginDup', 'lastName' =&gt; 'Zhou', 'email' =&gt; 'testLogin@gmail.com']);
      }
  
      /**
       * Register with incorrect password confirmation
       * @group register
       * @return void
       */
      public function testRegisterUserNoPassConfirm(){
  
          $this-&gt;browse(function ($browser){
              $browser-&gt;visit('/register')
                  -&gt;type('firstName', 'JenLoginPass')
                  -&gt;type('lastName', 'Zhou')
                  -&gt;type('email', 'testLoginPass@gmail.com')
                  -&gt;type('bio', 'Hello, this user is for testing login purposes!')
                  -&gt;type('location_zip', '11111')
                  -&gt;type('password', '123456')
                  -&gt;type('password_confirmation', '888888')
                  -&gt;click('.btn-primary')
                  -&gt;assertPathIs('/register')
                  -&gt;assertSee('The password confirmation does not match.');
          });
  
          $this-&gt;assertDatabaseMissing('users', ['firstName' =&gt; 'JenLoginPass', 'lastName' =&gt; 'Zhou', 'email' =&gt; 'testLoginPass@gmail.com']);
      }
  }
  </code></pre>