louposk's avatar

Start a Laravel Dusk test from inside a Laravel form

Hi guys, is there any way that i can run a laravel dusk test using a form? I would like to add the url in a form and when submit the button to run browser test using Dusk.

Something like this: https://ibb.co/mh6D9R

Thank you

0 likes
9 replies
bobbybouwmann's avatar

Well it should be possible I guess, but I've never done that. You first need to find a way to trigger dusk using a normal controller action I guess. So call the artisan command and see what happens in your application.

louposk's avatar

I have tried this but is does not work:

class DuskController extends Controller
{
    public function run() {
        \Artisan::call('dusk');
    }
}

I get "Command "dusk" is not defined."

louposk's avatar

I've also tried:

class DuskController extends Controller
{
    public function run() {
        $process = new Process('php artisan dusk');
        $process->run();
        $process->getOutput();
    }
}

with no luck either. The ddumps "Could not open input file: artisan".

Any other ideas??

Cronix's avatar

You might have to give it the full path to artisan. Not sure what default directory Process looks in.

Cronix's avatar

Ok, but did you try entering the full path to artisan?

$process = new Process('php /path/to/artisan dusk');

louposk's avatar

Oh, i know what you mean. I've enterned the below:

 public function run() {
        $process = new Process('php C:\mypath\artisan dusk');
        $process->run();
        dd($process->getOutput());
    }

I now get

Warning: TTY mode is not supported on Windows platform.\r\n
Could not open input file: vendor/phpunit/phpunit/phpunit\n

and nothing happened.

louposk's avatar

Even if i remove the dd line, still nothing happens.

Please or to participate in this conversation.