Skip to content
Technical solutions
  • Home
  • HTML
  • CSS
    • Introduction to Bootstrap
    • Bootstrap Components
  • Javascript
  • PHP
  • Project Management
    • What is Project Management
    • Improve team leadership skills
    • Strategies for Building High-Performing Teams
  • Cyber Security
    • What is cyber security
    • Cyber security best practices
    • Token-based authentication
  • Latest tech news
  • Blog
    • Development
    • Docker
    • Testing
    • JAVA
    • Domain
    • Laravel
    • ECommerce
    • Interview Questions
    • Website Design
Search

How to create laravel dusk test from Login page?

/ Laravel, Testing

create laravel LoginTest class using below artisan command:

php artisan dusk:make LoginTest
<?php
 namespace Tests\Browser;
 use Illuminate\Foundation\Testing\DatabaseMigrations;
 use Laravel\Dusk\Browser;
 use Tests\DuskTestCase;
 use App\Models\User;

 class LoginTest extends DuskTestCase
 {
     /**
      * A Dusk test for user login.
      *
      * @return void
      */
     public function testUserLogin()
     {

     $user = factory(User::class)->create([
              'email' =>'[email protected]',
          ]);
     $this->browse(function (Browser $browser) use ($user) {        
    $browser->visit('/login')                 
       ->assertSee('Login')                
       ->value('#email', $user->email)                
       ->value('#password', $user->password)                        ->press('Login')                
      ->assertPathIs('/home')                         ->assertSee('You are logged In!');     
     }); 
} 
 }

Now run below command to test the test cases:

php artisan dusk
← Previous Post
Next Post →

Recent Posts

  • DeepSeek AI: The Future of Artificial Intelligence
  • The Power of Design Systems: Bridging Product and Tech
  • What tree shaking in front-end development?
  • How to improve performance of a website?
  • Accessibility for developers and designers – checklist of development
  • How to make websites accessibility – importance of images and alt tags
  • Designing for diversity
  • What is accessibility and why it’s important for a website?
  • Boosting web development efficiency with VITE javascript build tool
  • Cookies vs. Sessions: What’s the Difference?

Categories

  • AWS
  • CSS
  • Design System
  • Development
  • Docker
  • Domain
  • ECommerce
  • Hosting
  • HTML
  • Interview Questions
  • JAVA
  • Javascript
  • Laravel
  • NODE
  • PHP
  • Scripting
  • Testing
  • Vue
  • Website Design
  • Wordpress

Australian Hosting Provider – Ventraip

Would You Like To Start A Project With Me?

Contact Me

Find best solutions for your technical problems on my website.

If you need website design, development and support services, visit my portfolio here.

Linkedin-in Envelope Github Stack-overflow

If I helped you solve your technical problem and you would like to thank me, you can buy me a coffee here. :)

Links

  • Home
  • About
  • Blog
  • Contact
  • Disclaimer

Get In Touch

  • Brisbane, Australia
  • [email protected]

learningwithmanjeet.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for us to earn fees by linking to Amazon.com and affiliated sites.

Copyright © 2025 Technical solutions. Site by Website Design Brisbane