tests: update to use snapshot for help output

This commit is contained in:
Owen Voke
2020-11-12 09:44:26 +00:00
parent feb6417f45
commit 200877d691
2 changed files with 131 additions and 2 deletions

View File

@ -1,6 +1,8 @@
<?php
test('visual snapshot of help command output', function () {
$snapshot = __DIR__ . '/../.snapshots/help-command.txt';
$output = function () {
$process = (new Symfony\Component\Process\Process(['php', 'bin/pest', '--help', '--colors=never']));
@ -9,5 +11,15 @@ test('visual snapshot of help command output', function () {
return $process->getOutput();
};
expect($output())->toContain('Pest Options:');
});
if (getenv('REBUILD_SNAPSHOTS')) {
// Strip versions from start of snapshot
$outputContent = preg_replace([
'/Pest \s+\d+\.\d+\.\d+\s+/m',
'/PHPUnit \d+\.\d+\.\d+\s+.*?\n/m'
], '', $output());
file_put_contents($snapshot, $outputContent);
}
expect($output())->toContain(file_get_contents($snapshot));
})->skip(PHP_OS_FAMILY === 'Windows');