diff --git a/features/steps/actor_cli_steps.py b/features/steps/actor_cli_steps.py index 57c270124..a6d53301c 100644 --- a/features/steps/actor_cli_steps.py +++ b/features/steps/actor_cli_steps.py @@ -1085,11 +1085,15 @@ def step_impl(context): @then("the actor command should fail with bad parameter") def step_impl(context): + import re + assert context.result.exit_code != 0 expected = getattr(context, "expected_error", None) if expected: - # Normalize whitespace to handle Rich text wrapping in narrow terminals - normalized = " ".join(context.result.output.split()) + # Strip ANSI escape codes and normalize whitespace to handle + # Rich formatting and text wrapping in narrow CI terminals + raw = re.sub(r"\x1b\[[0-9;]*[a-zA-Z]", "", context.result.output) + normalized = " ".join(raw.split()) assert expected in normalized, f"Expected '{expected}' in output: {normalized}" diff --git a/features/steps/auto_debug_cli_coverage_steps.py b/features/steps/auto_debug_cli_coverage_steps.py index 8d72e0324..90851c6ae 100644 --- a/features/steps/auto_debug_cli_coverage_steps.py +++ b/features/steps/auto_debug_cli_coverage_steps.py @@ -319,9 +319,13 @@ def step_assert_command_aborted(context): @then('the output should contain "{text}"') def step_assert_output_contains(context, text): + import re + output = _capture_output(context) - # Normalize whitespace to handle Rich text wrapping in narrow terminals - normalized = " ".join(output.split()) + # Strip ANSI escape codes and normalize whitespace to handle + # Rich formatting and text wrapping in narrow CI terminals + raw = re.sub(r"\x1b\[[0-9;]*[a-zA-Z]", "", output) + normalized = " ".join(raw.split()) assert text in normalized, f"Expected to find '{text}' in CLI output: {output}"