diff --git a/tests/.snapshots/allows-to-run-a-directory.txt b/tests/.snapshots/allows-to-run-a-directory.txt new file mode 100644 index 00000000..aaf96389 --- /dev/null +++ b/tests/.snapshots/allows-to-run-a-directory.txt @@ -0,0 +1,7 @@ + PASS Tests\Fixtures\DirectoryWithTests\ExampleTest + ✓ it example 1 + + PASS Tests\Fixtures\ExampleTest + ✓ it example 2 + + Tests: 2 passed diff --git a/tests/.snapshots/allows-to-run-a-single-test.txt b/tests/.snapshots/allows-to-run-a-single-test.txt new file mode 100644 index 00000000..0812d708 --- /dev/null +++ b/tests/.snapshots/allows-to-run-a-single-test.txt @@ -0,0 +1,4 @@ + PASS Tests\Fixtures\DirectoryWithTests\ExampleTest + ✓ it example 1 + + Tests: 1 passed diff --git a/tests/.snapshots/disable-decorating-printer.txt b/tests/.snapshots/disable-decorating-printer.txt new file mode 100644 index 00000000..dc804c2f --- /dev/null +++ b/tests/.snapshots/disable-decorating-printer.txt @@ -0,0 +1,5 @@ + + PASS Tests\Fixtures\DirectoryWithTests\ExampleTest + ✓ it example 1 + + Tests: 1 passed diff --git a/tests/.snapshots/has-ascii-chars.txt b/tests/.snapshots/has-ascii-chars.txt new file mode 100644 index 00000000..403f6ac7 --- /dev/null +++ b/tests/.snapshots/has-ascii-chars.txt @@ -0,0 +1,5 @@ + +  PASS  Tests\Fixtures\DirectoryWithTests\ExampleTest + ✓ it example 1 + + Tests: 1 passed diff --git a/tests/.snapshots/success.txt b/tests/.snapshots/success.txt index 82705172..294814f2 100644 --- a/tests/.snapshots/success.txt +++ b/tests/.snapshots/success.txt @@ -128,11 +128,11 @@ PASS Tests\Visual\SingleTestOrDirectory ✓ allows to run a single test ✓ allows to run a directory - ✓ it has ascii chars (decorated printer) + ✓ it has ascii chars ✓ it disable decorating printer when colors is set to never WARN Tests\Visual\Success s visual snapshot of test suite on success Tests: 6 skipped, 71 passed - Time: 2.89s + Time: 2.87s diff --git a/tests/Visual/SingleTestOrDirectory.php b/tests/Visual/SingleTestOrDirectory.php index 52ccf3e6..70222546 100644 --- a/tests/Visual/SingleTestOrDirectory.php +++ b/tests/Visual/SingleTestOrDirectory.php @@ -2,53 +2,42 @@ use Symfony\Component\Process\Process; -$run = function (string $target) { +$run = function (string $target, $decorated = false) { $process = new Process(['php', 'bin/pest', $target], dirname(__DIR__, 2)); $process->run(); - return preg_replace('#\\x1b[[][^A-Za-z]*[A-Za-z]#', '', $process->getOutput()); + return $decorated ? $process->getOutput() : preg_replace('#\\x1b[[][^A-Za-z]*[A-Za-z]#', '', $process->getOutput()); }; -test('allows to run a single test', function () use ($run) { - assertStringContainsString(<< file_get_contents(implode(DIRECTORY_SEPARATOR, [ + $testsPath, + '.snapshots', + "$name.txt", +])); - Tests: 1 passed -EOF, $run('tests/Fixtures/DirectoryWithTests/ExampleTest.php')); +test('allows to run a single test', function () use ($run, $snapshot) { + assertStringContainsString( + $snapshot('allows-to-run-a-single-test'), + $run('tests/Fixtures/DirectoryWithTests/ExampleTest.php')); }); -test('allows to run a directory', function () use ($run) { - assertStringContainsString(<<run(); - $output = $process->getOutput(); - assertStringContainsString(<<run(); $output = $process->getOutput(); - assertStringContainsString(<<