Skip to content

Commit

Permalink
Skip docker pull output from snapshot testing
Browse files Browse the repository at this point in the history
  • Loading branch information
Luc45 committed Oct 15, 2024
1 parent 2456ab9 commit 481f12b
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions _tests/custom_tests/tests/Traits/SnapshotHelpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ public function assertMatchesNormalizedSnapshot( string $actual, ?\Spatie\Snapsh
'npm',
];

$processing_docker_pull_output = false;

foreach ( explode( "\n", $actual ) as $line ) {
foreach ( $lines_to_remove as $to_remove ) {
if ( strpos( $line, $to_remove ) !== false ) {
Expand All @@ -40,6 +42,19 @@ public function assertMatchesNormalizedSnapshot( string $actual, ?\Spatie\Snapsh
continue;
}

/*
* Skip docker pull output.
*/
if ( strpos( $line, 'Unable to find image') !== false ) {
$processing_docker_pull_output = true;
continue;
} elseif ( $processing_docker_pull_output && strpos( $line, 'Downloaded newer image for' ) !== false ) {
$processing_docker_pull_output = false;
continue;
} elseif ( $processing_docker_pull_output ) {
continue;
}

// Normalize timings, eg "(8.9s)" or "(10.9s)", etc.
$line = preg_replace( '/\(\d+\.\d+s\)/', '(TIME)', $line );

Expand Down

0 comments on commit 481f12b

Please sign in to comment.