Modern QA2026Pipe/Chain Pattern — tiles
Log inJoin
40 / 80 · 12 Programming for QA · Functional Patterns for Testing← prev⊞ allnext →☰ Read as one page

5.6Pipe/Chain Pattern

Process data through a series of transformations, each step's output feeding the next step's input.

# Process test results through a pipeline
def load_results(path):
    with open(path) as f:
        return json.load(f)

def filter_failures(results):
    return [r for r in results if r["status"] == "FAIL"]

def enrich_with_duration(results):
    return [{**r, "slow": r["duration"] > 5.0} for r in results]

def format_report(results):
    return "\n".join(f"FAIL: {r['name']} ({r['duration']}s)" for r in results)

# Pipeline
results = load_results("results.json")
report = format_report(enrich_with_duration(filter_failures(results)))
// TypeScript: chaining with array methods
const report = testResults
    .filter(r => r.status === "FAIL")
    .map(r => ({ ...r, slow: r.duration > 5.0 }))
    .map(r => `FAIL: ${r.name} (${r.duration}s)${r.slow ? " [SLOW]" : ""}`)
    .join("\n");