joshhanley/livewire-dusk-extension
Composer 安装命令:
composer require joshhanley/livewire-dusk-extension
包简介
A Laravel Dusk testing helper extension for testing Livewire components.
README 文档
README
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.
joshhanley/livewire-dusk-extension 适用场景与选型建议
joshhanley/livewire-dusk-extension 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.01k 次下载、GitHub Stars 达 2, 最近一次更新时间为 2022 年 09 月 05 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 joshhanley/livewire-dusk-extension 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 joshhanley/livewire-dusk-extension 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 1.01k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 31
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-09-05