diff --git a/.github/workflows/update-test-badges.yml b/.github/workflows/update-test-badges.yml index 5660e56..4383b98 100644 --- a/.github/workflows/update-test-badges.yml +++ b/.github/workflows/update-test-badges.yml @@ -47,8 +47,9 @@ jobs: run: | OUTPUT=$(npm run test:run 2>&1) || true echo "$OUTPUT" - # Extract "Tests X passed" from output - PASSED=$(echo "$OUTPUT" | grep -oP 'Tests\s+\K\d+(?=\s+passed)' | tail -1) + # Strip ANSI escape codes, then extract "Tests X passed" from output + CLEAN=$(echo "$OUTPUT" | sed 's/\x1b\[[0-9;]*m//g') + PASSED=$(echo "$CLEAN" | grep -oP 'Tests\s+\K\d+(?=\s+passed)' | tail -1) echo "count=$PASSED" >> $GITHUB_OUTPUT - name: Run frontend tests and capture count @@ -60,8 +61,9 @@ jobs: run: | OUTPUT=$(npm run test:run 2>&1) || true echo "$OUTPUT" - # Extract "Tests X passed" from output - PASSED=$(echo "$OUTPUT" | grep -oP 'Tests\s+\K\d+(?=\s+passed)' | tail -1) + # Strip ANSI escape codes, then extract "Tests X passed" from output + CLEAN=$(echo "$OUTPUT" | sed 's/\x1b\[[0-9;]*m//g') + PASSED=$(echo "$CLEAN" | grep -oP 'Tests\s+\K\d+(?=\s+passed)' | tail -1) echo "count=$PASSED" >> $GITHUB_OUTPUT - name: Update README badges