From deb529b29793f30cfdc4592c13e473f8e1626e55 Mon Sep 17 00:00:00 2001 From: Alain Schlesser Date: Mon, 26 Jul 2021 09:11:45 +0200 Subject: [PATCH] Strip ANSI colors on string comparison --- src/Context/Support.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Context/Support.php b/src/Context/Support.php index 242fd03c..a4ae9570 100644 --- a/src/Context/Support.php +++ b/src/Context/Support.php @@ -51,6 +51,9 @@ protected function assert_not_numeric( $actual ) { } protected function check_string( $output, $expected, $action, $message = false ) { + // Strip ANSI color codes before comparing strings. + $output = preg_replace( '/\e[[][A-Za-z0-9];?[0-9]*m?/', '', $output ); + switch ( $action ) { case 'be': $r = rtrim( $output, "\n" ) === $expected;