39 lines
860 B
PHP
39 lines
860 B
PHP
<?php
|
|
|
|
namespace App\Console\Commands;
|
|
|
|
use Illuminate\Console\Command;
|
|
use Illuminate\Support\Facades\Process;
|
|
|
|
abstract class RunsPlaywrightScript extends Command
|
|
{
|
|
protected string $script;
|
|
protected int $processTimeout = 300;
|
|
|
|
public function handle(): int
|
|
{
|
|
$this->info("Running {$this->script}...");
|
|
|
|
$result = Process::path(base_path('playwright'))
|
|
->timeout($this->processTimeout)
|
|
->run("npx playwright test {$this->script} --reporter=line");
|
|
|
|
$this->line($result->output());
|
|
|
|
if (! $result->successful()) {
|
|
$this->error($result->errorOutput());
|
|
return self::FAILURE;
|
|
}
|
|
|
|
$this->afterRun();
|
|
|
|
$this->info('Done.');
|
|
return self::SUCCESS;
|
|
}
|
|
|
|
protected function afterRun(): void
|
|
{
|
|
// no-op by default
|
|
}
|
|
}
|