From 481f12bd4c87eb132e925b344723e21ce2b69585 Mon Sep 17 00:00:00 2001 From: Lucas Bustamante Date: Mon, 14 Oct 2024 21:34:59 -0300 Subject: [PATCH] Skip docker pull output from snapshot testing --- .../custom_tests/tests/Traits/SnapshotHelpers.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/_tests/custom_tests/tests/Traits/SnapshotHelpers.php b/_tests/custom_tests/tests/Traits/SnapshotHelpers.php index f13232b8..1cd9965f 100644 --- a/_tests/custom_tests/tests/Traits/SnapshotHelpers.php +++ b/_tests/custom_tests/tests/Traits/SnapshotHelpers.php @@ -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 ) { @@ -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 );