konsulting/dusk-standalone 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

konsulting/dusk-standalone

最新稳定版本:7.0.0

Composer 安装命令:

composer require konsulting/dusk-standalone

包简介

Standalone dusk testing, ideal for legacy projects, or remote testing.

README 文档

README

A simple package to use Laravel Dusk with PHPUnit outside of a Laravel application for browser testing.

The package was put together to allow local and remote testing of legacy applications which do not have similar testing frameworks available. There are other options for doing so, but we like the API for Dusk.

Perhaps not everything will work as expected, since we're not integrated to Laravel. It's early days for this package, so it's open to improvement.

We also assist with another package, designed for using Laravel Dusk to test Laravel Packages, Orchestra Testbench-Dusk.

Build Status Latest Stable Version Total Downloads Latest Unstable Version License StyleCI

Version Compatibility

The versioning for this package aligns with major releases of Dusk.

Dusk   Dusk Standalone
1.x 1.x
2.x 2.x
3.x 3.x
4.x 4.x
5.x 5.x
6.x 6.x
7.x 7.x

Installation

We recommend using composer.

composer require konsulting/dusk-standalone

Usage

We tend to put our Browser tests in tests/Browser. Create a new base testcase that extends the Konsulting\DuskStandalone\TestCase.

This will allow you to add any customisations you want in your Dusk tests.

<?php

namespace Application\Tests;

use Konsulting\DuskStandalone\TestCase;

abstract class DuskTestCase extends TestCase
{
    // Set the base url for the browser requests
    protected function baseUrl()
    {
        return 'https://www.klever.co.uk';
    }

    // Set the path for browser tests, this is where screenshots/console logs
    // are stored. The default is [app root]/tests/Browser based on the 
    // vendor folder location as per a normal Composer install.
    protected function browserTestsPath()
    {
        return parent::browserTestsPath();
    }

    // Set the default user - however... this is only useful if you will be
    // using the Dusk type login. It's worth reviewing the Laravel Dusk
    // trait InteractsWithAuthentication to combine with your app.
    protected function user()
    {
        return parent::user();
    }
}

Now create a your tests:

<?php

namespace Application\Tests\Browser;

use Laravel\Dusk\Browser;
use Konsulting\DuskStandalone\Tests\DuskTestCase;

class ExampleTest extends DuskTestCase
{
    /** @test * */
    public function it_can_browse_a_site()
    {
        $this->browse(function (Browser $browser) {
            $browser->visit('/')->assertSee('Klever');
        });
    }
}

Run your tests as part of your testsuite, or separate them out to run on their own (since browser tests can be slow).

Dusk documentation can be found here

Authentication

If you are able to add Dusk Login routes to your application, and for those to be secure, you will be able to use the standard dusk login, loginAs, logout and other methods.

If that is not possible, you can leverage the 'Macroable' nature of the Browser class to add custom methods at runtime. Take care to not try to overwite an existing method on the Browser class.

For example:

<?php
    // In your testing bootstrap file.

    \Laravel\Dusk\Browser::macro('customLoginAs', function ($user, $pass) {
        $this->browse('login_url')
            ->type('username', $user)
            ->type('pasword', $pass)
            ->press('Login');
    });

Chrome Version

If you receive an error containing information about the Chrome version (e.g. Chrome version must be between 70 and 73)

Please run vendor/bin/dusk-updater update

For further information please see the Dusk Updater project

Contributing

Contributions are welcome and will be fully credited. We will accept contributions by Pull Request.

Please:

  • Use the PSR-2 Coding Standard
  • Add tests, if you’re not sure how, please ask.
  • Document changes in behaviour, including readme.md.

Testing

We use PHPUnit

Run tests using PHPUnit: vendor/bin/phpunit

konsulting/dusk-standalone 适用场景与选型建议

konsulting/dusk-standalone 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 46.62k 次下载、GitHub Stars 达 20, 最近一次更新时间为 2018 年 01 月 30 日, 在 PHP 生态内属于活跃度较高的组件。

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

围绕 konsulting/dusk-standalone 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

  • 总下载量: 46.62k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 20
  • 点击次数: 13
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 20
  • Watchers: 3
  • Forks: 4
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-01-30