diff --git a/src/Plugins/Snapshot.php b/src/Plugins/Snapshot.php index 717512c2..5022caa7 100644 --- a/src/Plugins/Snapshot.php +++ b/src/Plugins/Snapshot.php @@ -5,7 +5,6 @@ declare(strict_types=1); namespace Pest\Plugins; use Pest\Contracts\Plugins\HandlesArguments; -use Pest\Exceptions\InvalidOption; use Pest\TestSuite; /** @@ -20,12 +19,12 @@ final class Snapshot implements HandlesArguments */ public function handleArguments(array $arguments): array { - if (! $this->hasArgument('--update-snapshots', $arguments)) { + if (Parallel::isWorker()) { return $arguments; } - if ($this->hasArgument('--parallel', $arguments)) { - throw new InvalidOption('The [--update-snapshots] option is not supported when running in parallel.'); + if (! $this->hasArgument('--update-snapshots', $arguments)) { + return $arguments; } TestSuite::getInstance()->snapshots->flush(); diff --git a/src/Repositories/SnapshotRepository.php b/src/Repositories/SnapshotRepository.php index c719f219..30b31546 100644 --- a/src/Repositories/SnapshotRepository.php +++ b/src/Repositories/SnapshotRepository.php @@ -59,8 +59,10 @@ final class SnapshotRepository { $snapshotFilename = $this->getSnapshotFilename(); - if (! file_exists(dirname($snapshotFilename))) { - mkdir(dirname($snapshotFilename), 0755, true); + $directory = dirname($snapshotFilename); + + if (! is_dir($directory)) { + @mkdir($directory, 0755, true); } file_put_contents($snapshotFilename, $snapshot);