Get support for joshhanley/livewire-dusk-extension
If you're new to LTH, please see our FAQ for more information on what it is we do.
Support Options
Unfortunately, there are currently no active helpers for this repository on the platform. Until they become available, we reccomend the following actions:
View Open IssuesTake a look to see if anyone else has experienced the same issue as you and if they managed to solve it.
Open an IssueMake sure to read any relevant guidelines for opening issues on this repo before posting a new issue.
Sponsor directlyCheck out the page and see if there are any options to sponsor this project or it's developers directly.
joshhanley/livewire-dusk-extension
Livewire Dusk Extension
Livewire Dusk Extension adds support for testing individual Livewire components in your app with Laravel Dusk.
Getting Started
It's recommended you read the documentation of these packages before going through this document:
Installation
To install through composer, run the following command from terminal:
composer require --dev joshhanley/livewire-dusk-extension
Usage
To use this package you need to:
Ensure Laravel Dusk is installed and configured
Ensure Laravel Dusk is installed and configured as per the Laravel Dusk documentation
Update DuskTestCase
Laravel Dusk creates a file tests\DuskTestCase.php
which needs to be updated to extend LivewireDuskExtension
use LivewireDuskExtension\LivewireDuskExtensionTestCase;
abstract class DuskTestCase extends LivewireDuskExtensionTestCase
Configure Tests Directory and Namespace
This package assumes you have a tests\Browser
directory at the root of your project and that it's namespace is Tests\Browser
.
If you have a different configuration, you can publish the Livewire Dusk Extension config and specify your tests namespaces and directories.
To publish the config run
php artisan vendor:publish --provider="LivewireDuskExtension\LivewireDuskExtensionServiceProvider"
Then open the config and update the test-directories
array with your tests namespace and directory details, with the namespace being the key and the directory is the value.
'test-directories' => [
'My\\Custom\\Namespace' => base_path('my/custom/namespace'),
],
Create a Test
You can now create a dusk test that uses $browser->livewire()
to test your component.
To do this, pass the class name of the component you want to test into the $browser->livewire()
method.
Then you can chain assertions from the livewire()
call.
public function testExample()
{
$this->browse(function (Browser $browser) {
$browser->livewire(SampleComponent::class)
->assertSee('Sample!');
});
}
Using a Test Component
If you don't want to test a Livewire component that exists in your app, and instead want to test something like a Blade Component that has Livewire interactivity, then you can create a test Livewire component.
In the same directory as your test, create a Livewire component and reference that in your test. This package will autoload the component for you.
Then in your test component you can include any Blade Components or Alpine, etc that you want to test out.
Troubleshooting
This is just a convenience wrapper around Laravel Dusk to make testing Livewire Components in your app easier.
Consult the documentation for the relevant packages for troubleshooting.
Our Mission
We want to make open source more sustainable. The entire platform was born from this and everything we do is in aid of this.
From the Blog
Interesting Articles
-
Generating income from open source
Jun 23 • 8 min read
-
2023 State of OSS
Apr 23 • 45 min read ★
-
A funding experiment...
Aug 19 • 10 min read
-
But You Said I could
Aug 19 • 2 min read
Thank you for checking out LiveTechHelper |
2025 © lth-dev incorporated
p-e622a1a2