Jump into concepts and practice - no test required
or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Recall & Review
beginner
What is Laravel Dusk used for?
Laravel Dusk is a tool for browser testing. It lets you automate browser actions to check if your web app works correctly from a user's view.
Click to reveal answer
beginner
How do you start a Dusk test in Laravel?
You create a test class using the command <code>php artisan dusk:make TestName</code>. Then you write browser actions inside the test methods.
Click to reveal answer
beginner
What method do you use to visit a page in a Dusk test?
Use $browser->visit('/url') to open a page in the browser during a test.
Click to reveal answer
beginner
How can you check if a page contains specific text in Dusk?
Use $browser->assertSee('text') to confirm the page shows the given text.
Click to reveal answer
beginner
Why is browser testing important in web development?
Browser testing checks if your app works well for users in real browsers. It finds problems that unit tests might miss, like layout or interaction issues.
Click to reveal answer
Which command creates a new Dusk test in Laravel?
Aphp artisan test:dusk TestName
Bphp artisan make:test TestName
Cphp artisan dusk:make TestName
Dphp artisan dusk:create TestName
✗ Incorrect
The correct command to create a Dusk test is php artisan dusk:make TestName.
What does $browser->visit('/home') do in a Dusk test?
AOpens the '/home' page in the browser
BCloses the browser
CChecks if '/home' text is visible
DClicks a button named 'home'
✗ Incorrect
The visit method opens the specified URL in the browser during the test.
How do you verify that a page shows the text 'Welcome' in Dusk?
A$browser->seeText('Welcome')
B$browser->assertSee('Welcome')
C$browser->checkText('Welcome')
D$browser->verify('Welcome')
✗ Incorrect
Use assertSee to check if the page contains specific text.
Which of these is NOT a benefit of browser testing with Dusk?
AReplacing all unit tests
BTesting user interactions in a real browser
CFinding layout problems
DAutomating repetitive browser tasks
✗ Incorrect
Dusk complements unit tests but does not replace them.
What is the default browser used by Laravel Dusk for testing?
AFirefox
BSafari
CEdge
DChrome
✗ Incorrect
Laravel Dusk uses a ChromeDriver instance to run tests in a Chrome browser by default.
Explain how you would write a simple Dusk test to check if the homepage loads and shows the text 'Laravel'.
Think about the steps to open a page and check for text.
You got /3 concepts.
Describe why browser testing with Dusk is useful compared to just running unit tests.
Consider what unit tests cannot check.
You got /4 concepts.
Practice
(1/5)
1. What is the primary purpose of Laravel Dusk in web development?
easy
A. To optimize website images for faster loading
B. To automate browser testing by simulating user actions
C. To generate API documentation
D. To create database migrations automatically
Solution
Step 1: Understand Laravel Dusk's role
Laravel Dusk is designed to automate browser testing by controlling a real browser to simulate user actions like clicking and typing.
Step 2: Compare options with Dusk's purpose
Options A, B, and C relate to optimization, database, and documentation, which are unrelated to browser testing.
Final Answer:
To automate browser testing by simulating user actions -> Option B
Quick Check:
Browser automation = To automate browser testing by simulating user actions [OK]
Hint: Remember: Dusk controls browsers to test user actions [OK]
Common Mistakes:
Confusing Dusk with database tools
Thinking Dusk generates documentation
Assuming Dusk optimizes assets
2. Which of the following is the correct way to start a browser test with Laravel Dusk?
easy
A. $browser->navigate('/home')->expectText('Welcome');
B. $browser->open('/home')->checkText('Welcome');
C. $browser->goTo('/home')->verifyText('Welcome');
D. $browser->visit('/home')->assertSee('Welcome');
Solution
Step 1: Recall Laravel Dusk syntax for visiting pages
The correct method to visit a page is visit(), and to check text is assertSee().
Step 2: Identify correct method names
Options B, C, and D use incorrect method names like open(), goTo(), and navigate(), which do not exist in Dusk.
Final Answer:
$browser->visit('/home')->assertSee('Welcome'); -> Option D
Quick Check:
Use visit() and assertSee() in Dusk [OK]
Hint: Use visit() to open page and assertSee() to check text [OK]
Common Mistakes:
Using non-existent methods like open() or goTo()
Confusing assertSee() with verifyText()
Mixing up method chaining order
3. Given the following Dusk test code, what will be the result?
A. The method click() should be press() to click buttons
B. The type() method cannot fill text inputs
C. assertSee() cannot check text on the page
D. visit() method requires a full URL, not a path
Solution
Step 1: Review Dusk methods for clicking buttons
In Laravel Dusk, to click a button by its text, the correct method is press(), not click().
Step 2: Validate other methods
type() fills inputs, assertSee() checks text, and visit() accepts paths, so these are correct.
Final Answer:
The method click() should be press() to click buttons -> Option A
Quick Check:
Use press() for buttons, not click() [OK]
Hint: Use press() to click buttons, not click() [OK]
Common Mistakes:
Using click() instead of press() for buttons
Thinking type() can't fill inputs
Believing visit() needs full URL
5. You want to test a form that has a dropdown with options 'Red', 'Green', and 'Blue'. Which Dusk method correctly selects 'Green' before submitting the form?
hard
A. $browser->pick('color', 'Green')->press('Submit');
B. $browser->choose('color', 'Green')->press('Submit');
C. $browser->select('color', 'Green')->press('Submit');
D. $browser->set('color', 'Green')->press('Submit');
Solution
Step 1: Recall the method to select dropdown options in Dusk
The correct method to select an option from a dropdown is select().
Step 2: Verify other options are invalid
Methods like choose(), pick(), and set() do not exist or are incorrect for dropdown selection in Dusk.
Final Answer:
$browser->select('color', 'Green')->press('Submit'); -> Option C
Quick Check:
Use select() for dropdowns in Dusk [OK]
Hint: Use select() to pick dropdown options before pressing buttons [OK]