laravel-dusk
БесплатноБез исполняемых скриптовНе проверенLaravel Dusk - Browser automation and testing API for Laravel applications. Use when writing browser tests, automating UI testing, testing JavaScript…
Об этом скилле
Laravel Dusk Skill
Comprehensive assistance with Laravel Dusk browser automation and testing, providing expert guidance on writing expressive, easy-to-use browser tests for your Laravel applications.
When to Use This Skill
This skill should be triggered when:
- Writing or debugging browser automation tests for Laravel
- Testing user interfaces and JavaScript interactions
- Implementing end-to-end (E2E) testing workflows
- Setting up automated UI testing in Laravel applications
- Working with form submissions, authentication flows, or page navigation tests
- Configuring ChromeDriver or alternative browser drivers
- Using the Page Object pattern for test organization
- Testing Vue.js components or waiting for JavaScript events
- Troubleshooting browser test failures or timing issues
Quick Reference
1. Basic Browser Test
public function testBasicExample(): void
{
$this->browse(function (Browser $browser) {
$browser->visit('/login')
->type('email', '[email protected]')
->type('password', 'password')
->press('Login')
->assertPathIs('/home');
});
}
2. Using Dusk Selectors (Recommended)
<!-- In your Blade template -->
<button dusk="login-button">Login</button>
<input dusk="email-input" name="email" />
// In your test - use @ prefix for dusk selectors
$browser->type('@email-input', '[email protected]')
->click('@login-button');
3. Testing Multiple Browsers
public function testMultiUserInteraction(): void
{
$this->browse(function (Browser $first, Browser $second) {
$first->loginAs(User::find(1))
->visit('/home');
$second->loginAs(User::find(2))
->visit('/home');
});
}
4. Waiting for Elements
// Wait for element to appear
$browser->waitFor('.modal')
->assertSee('Confirmation Required');
// Wait for text to appear
$browser->waitForText('Hello World');
// Wait for JavaScript condition
$browser->waitUntil('App.data.servers.length > 0');
// Wait when element is available
$browser->whenAvailable('.modal', function (Browser $modal) {
$modal->assertSee('Delete Account')
->press('OK');
});
5. Form Interactions
// Text input
$browser->type('email', '[email protected]')
->append('notes', 'Additional text')
->clear('description');
// Dropdown selection
$browser->select('size', 'Large')
->select('categories', ['Art', 'Music']); // Multiple
// Checkboxes and radio buttons
$browser->check('terms')
->radio('gender', 'male');
// File upload
$browser->attach('photo', __DIR__.'/photos/profile.jpg');
6. Page Object Pattern
// Generate page object
// php artisan dusk:page Login
// app/tests/Browser/Pages/Login.php
class Login extends Page
{
public function url(): string
{
return '/login';
}
public function elements(): array
{
return [
'@email' => 'input[name=email]',
'@password' => 'input[name=password]',
'@submit' => 'button[type=submit]',
];
}
public function login(Browser $browser, $email, $password): void
{
$browser->type('@email', $email)
->type('@password', $password)
->press('@submit');
}
}
// Use in test
$browser->visit(new Login)
->login('[email protected]', 'password')
->assertPathIs('/dashboard');
7. Browser Macros (Reusable Methods)
// In AppServiceProvider or DuskServiceProvider
use Laravel\Dusk\Browser;
Browser::macro('scrollToElement', function (string $element) {
$this->script("$('html, body').animate({
scrollTop: $('{$element}').offset().top
}, 0);");
return $this;
});
// Use in tests
$browser->scrollToElement('#footer')
->assertSee('Copyright 2024');
8. Database Management in Tests
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Illuminate\Foundation\Testing\DatabaseTruncation;
class ExampleTest extends DuskTestCase
{
// Option 1: Run migrations before each test (slower)
use DatabaseMigrations;
// Option 2: Truncate tables after first migration (faster)
use DatabaseTruncation;
// Exclude specific tables from truncation
protected $exceptTables = ['migrations'];
}
9. JavaScript Execution
// Execute JavaScript
$browser->script('document.documentElement.scrollTop = 0');
// Get JavaScript return value
$path = $browser->script('return window.location.pathname');
// Wait for reload after action
$browser->waitForReload(function (Browser $browser) {
$browser->press('Submit');
})->assertSee('Success');
10. Common Assertions
// Page assertions
$browser->assertPathIs('/dashboard')
->assertRouteIs('dashboard')
->assertTitle('Dashboard')
->assertSee('Welcome Back')
->assertDontSee('Error');
// Form assertions
$browser->assertInputValue('email', '[email protected]')
->asse
Установить laravel-dusk в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл laravel-dusk?
Laravel Dusk - Browser automation and testing API for Laravel applications. Use when writing browser tests, automating UI testing, testing JavaScript interactions, or implementing end-to-end tests in Laravel.
Как установить скилл laravel-dusk?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл laravel-dusk запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
doc-coauthoring
Guide users through a structured workflow for co-authoring documentation. Use when user wants to write documentation, proposals, technical specs, decision…
от Anthropicacademy-guide
Stop and check this skill before finishing any reply to a question about how to use Claude or a Claude product — it recommends matching courses, tutorials…
от Anthropicinternal-comms
A set of resources to help me write all kinds of internal communications, using the formats that my company likes to use. Claude should use this skill…
от Anthropicskill-development
This skill should be used when the user wants to "create a skill", "add a skill to plugin", "write a new skill", "improve skill description", "organize skill…
от Anthropic