承接 stechstudio/laravel-visual-testing 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

stechstudio/laravel-visual-testing

Composer 安装命令:

composer require stechstudio/laravel-visual-testing

包简介

Visual UI testing for Laravel Dusk using percy.io

README 文档

README

Latest Version on Packagist Software License Build Status

This package extends Dusk with the ability to do visual diffs with the Percy visual testing platform.

Why write visual tests?

If you are new to the idea of visual testing we recommend reading through Visual testing and visual diffs on the Percy blog.

Sometimes called visual regression testing or UI testing, visual testing is the process of automatically discovering and reviewing software for perceptual changes.

Visual testing is all about what your users actually see and interact with.

This form of testing is very useful in cases where you want to guard against unexpected changed to your UI. Visual testing is not meant to replace your Laravel unit/feature/browser tests, but rather provide another tool in your testing toolbox.

Getting started

This package integrates with Laravel Dusk. If you haven't already, first go through the Dusk installation steps and make sure you can run the example test with php artisan dusk.

Next:

  1. Sign up for a free account at percy.io and create your first project. Put your PERCY_TOKEN in your Laravel .env file (or specific dusk environment files if you are using those).

    PERCY_TOKEN=aaabbbcccdddeeefff
    
  2. Install the @percy/agent NPM package.

    npm install --save-dev @percy/agent
    
  3. Install this composer package.

    composer require stechstudio/laravel-visual-testing --dev
    

How to use

To take a snapshot call snapshot() on the browser instance in any of your Dusk tests.

$browser->visit('/auth/login')
        ->snapshot();

Then run your test suite like your normally would.

php artisan dusk

Naming your snapshots

By default the name of your snapshot will be the relative URL of the page (e.g. /auth/login). You can also pass in your own name when taking the snapshot.

$browser->visit('/auth/login')
        ->snapshot('Login page');

Snapshot options

You can pass in an array of options when taking a snapshot:

  • widths: An array of integers representing the browser widths at which you want to take snapshots.
  • minHeight: An integer specifying the minimum height of the resulting snapshot, in pixels. Defaults to 1024px.
$browser->visit('/auth/login')
        ->snapshot('Login page', [ 'widths' => [768, 992, 1200] ]);

Disabling snapshots

If you want to run your tests without snapshots, use the --without-percy command line option.

Selecting base build branch

Percy uses a variety of strategies to determine the optimal base build for comparison. For details see Base build selection.

If you want to override and specify your own base you have two options:

  • --percy-target-branch : Specify base by branch name
  • --percy-target-commit : Specify by target commit SHA (only works if there is a finished Percy build for that commit)

Basic example

Open the example test at tests/Browser/ExampleTest.php. Add a call to snapshot() right after the visit, and pass in a name for your snapshot.

public function testBasicExample()
{
    $this->browse(function (Browser $browser) {
        $browser->visit('/')
            ->snapshot('basic-example') // <-- add this
            ->assertSee('Laravel');
                
    });
}

Now go run your test:

php artisan dusk

If all goes well, you should see output similar to this:

$ php artisan dusk
[percy] created build #1
[percy] percy has started.

[percy] snapshot taken: 'basic-example'
.                                                                   1 / 1 (100%)

Time: 2.37 seconds, Memory: 22.00MB

OK (1 test, 1 assertion)
[percy] stopping percy...
[percy] waiting for 1 snapshots to complete...
[percy] done.
[percy] finalized build #1

Now go check out your Percy dashboard, and you should see the new build.

At this point it won't have anything to compare the snapshot to. But if you go modify the welcome.blade.php file and run it again, you'll get a nice visual diff of your change.

stechstudio/laravel-visual-testing 适用场景与选型建议

stechstudio/laravel-visual-testing 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 65.36k 次下载、GitHub Stars 达 33, 最近一次更新时间为 2019 年 01 月 28 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 stechstudio/laravel-visual-testing 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 stechstudio/laravel-visual-testing 我们能提供哪些服务?
定制开发 / 二次开发

基于 stechstudio/laravel-visual-testing 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 65.36k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 33
  • 点击次数: 15
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 33
  • Watchers: 4
  • Forks: 9
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-01-28