Giter Club home page Giter Club logo

oc-dusktests-plugin's Introduction

OctoberCMS Laravel Dusk Plugin

日本語版はこちら

This plugin enables to use Laravel Dusk test framework in OctoberCMS projects.

Usage

Installation

Installation options are;

  • OctoberCMS UI (not yet available now)
  • Composer
  • Manual git clone

With Composer

Execute below at the root of your project:

composer require --dev pikanji/dusktests-plugin
php artisan dusk:install

Manual Git Clone

Although composer is still required to install dependencies, you can install this plugin without adding it to your composer.json. In the plugins directory of your project, create pikanji directory and simply execute git clone in it.

cd plugins
mkdir pikanji
cd pikanji
git clone [email protected]:pikanji/oc-dusktests-plugin.git dusktests

Execute below at the root of your project.

composer update
php artisan dusk:install

Executing Tests

Dusk comes with example test (tests/Browser/ExampleTest.php). You can test setup by running this test.

Fix Example Test

ExampleTest.php checks if a string "Laravel" is found in the loaded web page. Assuming that your are using fresh copy of demo theme, change "Laravel" to "October CMS" in ExampleTest.php to let the test pass.

public function testBasicExample()
{
    $this->browse(function (Browser $browser) {
        $browser->visit('/')
                ->assertSee('October CMS');
    });
}

Run Tests

Assuming you are running your web server on your local machine for testing and Chrome browser is installed, execute below at the root of your project. If you are running web server on Docker container see here in addition to this instruction.

php artisan dusk

Test could be very slow. Leave it for a couple minutes to see if it has progress.

Screenshots are stored in tests/Browser/screenshots by default. There might be some configuration to change it.

Extending Timeout

If you get timeout error, you can try extending timeout like below in tests/DuskTestCase.php. In my case, 1 minute was not enough. So, I made it 3 minutes.

return RemoteWebDriver::create(
    'http://192.168.1.115:4444/wd/hub', DesiredCapabilities::chrome()->setCapability(
        ChromeOptions::CAPABILITY, $options
    ), 180*1000, 180*1000
);

Using Docker Container

See here in addition to this instruction.

oc-dusktests-plugin's People

Contributors

meysammahfouzi avatar pikanji avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

oc-dusktests-plugin's Issues

DuskTestCase.php not found

Hi and thanks for trying to bring dusk to OctoberCMS!
I think there should be some file called DuskTestCase.php in the tests directory for the plugin to work. At the moment when I run composer update I get this error:

[RuntimeException]
Could not scan for classes inside "plugins/pikanji/dusktests/../../../tests/DuskTestCase.php" which does not appear to be a file nor a folder

Could you please provide the missing file?
Thanks 🙂

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.