christophrumpel/missing-livewire-assertions
Composer 安装命令:
composer require christophrumpel/missing-livewire-assertions
包简介
This package adds missing livewire test assertions.
README 文档
README
This Package Adds Missing Livewire Test Assertions
This package adds some nice new Livewire assertions which I was missing while testing my applications using Livewire. If you want to know more about WHY I needed them, check out my blog article.
➡️ Version 2.0 of this package only supports Livewire 3. Please use a lower version of this package for other Livewire versions.
Installation
You can install the package via composer:
composer require christophrumpel/missing-livewire-assertions
Usage
The new assertions get added automatically, so you can use them immediately.
Check if a Livewire property is wired to an HTML field
Livewire::test(FeedbackForm::class) ->assertPropertyWired('email');
It looks for a string like wire:model="email" in your component's view file. It also detects variations like wire:model.live="email", wire:model.lazy="email", wire:model.debounce="email", wire:model.lazy.10s="email" or wire:model.debounce.500ms="email".
Check if a Livewire method is wired to an HTML field
Livewire::test(FeedbackForm::class) ->assertMethodWired('submit');
It looks for a string like wire:click="submit" in your component's view file.
Check if a Livewire magic action is wired to an HTML field
Livewire::test(FeedbackForm::class) ->assertMethodWired('$toggle(\'sortAsc\')');
Check if a generic Livewire method is wired to an HTML field
Livewire::test(FeedbackForm::class) ->assertMethodWiredToAction('mouseenter', 'enter');
It looks for a string like wire:mouseenter="enter" in your component's view file. Also, note that it can also look for any events, like wire:keydown or wire:custom-event.
It looks for a string like wire:click="$refresh", wire:click="$toggle('sortAsc'), $dispatch('post-created'), along with all other magic actions. When testing for magic actions, you must escape single quotes like shown above.
Check if a Livewire method is wired to an HTML form
Livewire::test(FeedbackForm::class) ->assertMethodWiredToForm('upload');
It looks for a string like wire:submit.prevent="upload" in your component's view file.
Check if a Livewire method is wired to a specific javascript event
Livewire::test(FeedbackForm::class) ->assertMethodWiredToEvent('setValue', 'change');
It looks for a string like wire:change.debounce.150ms="setValue" in your component's view file.
You can also check for actions without any additional modifiers:
Livewire::test(FeedbackForm::class) ->assertMethodWiredToEventWithoutModifiers('reset', 'keyup');
This will match wire:keyup="reset", but not wire:keyup.escape="reset". You could match that with
Livewire::test(FeedbackForm::class) ->assertMethodWiredToEventWithoutModifiers('reset', 'keyup.escape');
Check if a Livewire component contains another Livewire component
Livewire::test(FeedbackForm::class) ->assertContainsLivewireComponent(CategoryList::class);
You can use the component tag name as well:
Livewire::test(FeedbackForm::class) ->assertContainsLivewireComponent('category-list');
Check if a Livewire component contains a Blade component
Livewire::test(FeedbackForm::class) ->assertContainsBladeComponent(Button::class);
You can use the component tag name as well:
Livewire::test(FeedbackForm::class) ->assertContainsBladeComponent('button');
Check to see if a string comes before another string
Livewire::test(FeedbackForm::class) ->assertSeeBefore('first string', 'second string');
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
License
The MIT License (MIT). Please see License File for more information.
christophrumpel/missing-livewire-assertions 适用场景与选型建议
christophrumpel/missing-livewire-assertions 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 408.01k 次下载、GitHub Stars 达 150, 最近一次更新时间为 2021 年 04 月 20 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「laravel」 「assertions」 「christophrumpel」 「livewire」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 christophrumpel/missing-livewire-assertions 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 christophrumpel/missing-livewire-assertions 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 christophrumpel/missing-livewire-assertions 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Additional assertions for PHPUnit
Custom annotations and expectations for PHPUnit.
This package lets a user pick a file or class from a list during a Laravel command.
A collection of helpers for PHPUnit to ease testing Tarantool libraries.
This package sits on top of Laravel factories and provides you with dedicated factory classes for every model.
Laravel-specific Testing Helpers and Assertions.
统计信息
- 总下载量: 408.01k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 150
- 点击次数: 20
- 依赖项目数: 7
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2021-04-20
