Delivery 2 Reusable Quality Utilities
This TypeScript project accompanies Part II, Delivery 2 of the MSQE handbook. It extends the Delivery 1 quality-evidence ideas without becoming an API-testing framework, a configuration framework, or a production reporting service.
It demonstrates how a small Quality Engineering utility can make its boundaries visible:
external configuration
→ trusted QualityToolConfig
→ file read
→ JSON.parse as unknown
→ runtime validation of the source shape
→ canonical normalisation
→ pure summary
→ report formatting
→ file write
Contents
src/models.tsdefines the trusted internal data and configuration contracts.src/validation.tsvalidates unknown runtime values before other modules use them.src/normalisation.ts,src/summary.ts, andsrc/reporting.tscontain focused, deterministic transformations.src/configuration.tsconverts an explicitly supplied string environment intoQualityToolConfig; it does not readprocess.envitself.src/fileSystem.tsis the Node.js filesystem adapter.src/workflow.tscomposes the stages and receives its filesystem dependency explicitly.src/runIllustrativeExample.tssupplies safe local example values and runs againstfixtures/quality-executions.json.src/runFromProcessEnvironment.tsis the outer process boundary for an actual environment-based run.
The fixture is fictional and contains no credentials, customer data, tokens, or private keys. The .gitignore excludes .env files and generated output; a real secret must never be committed to this repository or printed in an error message.
Install and Validate
Use Node.js 20 or later with npm.
npm ci
npm run check
npm run build
npm run start
npm run validate
npm run start writes .build/quality-summary.json and prints this summary:
{
"executionCount": 3,
"failedExecutionCount": 1,
"slowExecutionCount": 2,
"failureCountByEndpoint": {
"POST /orders": 1
},
"slowEndpoints": [
"GET /catalogue",
"POST /orders"
]
}
Run with Actual Environment Values
The outer runner is intentionally separate from the reusable configuration loader. Supply configuration before invoking it; the following syntax is suitable for a POSIX-compatible shell:
QE_ENVIRONMENT=staging \
QE_SLOW_RESPONSE_THRESHOLD_MS=750 \
QE_INPUT_PATH=fixtures/quality-executions.json \
QE_OUTPUT_PATH=.build/quality-summary-from-environment.json \
npm run start:environment
QE_ENVIRONMENT and QE_INPUT_PATH are required. QE_SLOW_RESPONSE_THRESHOLD_MS defaults to 750 only because this teaching utility has an explicitly documented local example threshold; a delivery decision should not silently inherit an unexplained default. QE_OUTPUT_PATH defaults to .build/quality-summary.json when it is absent or contains only whitespace.
The command above uses POSIX shell syntax. In PowerShell, set the values first, then run the command:
$env:QE_ENVIRONMENT = "staging"
$env:QE_SLOW_RESPONSE_THRESHOLD_MS = "750"
$env:QE_INPUT_PATH = "fixtures/quality-executions.json"
$env:QE_OUTPUT_PATH = ".build/quality-summary-from-environment.json"
npm run start:environment
Environment values are external text, not trusted typed configuration. For example, QE_SLOW_RESPONSE_THRESHOLD_MS=slow produces a useful configuration error rather than allowing NaN into the summary rule. Records must contain an integer HTTP statusCode between 100 and 599. A missing fixture, malformed JSON, or malformed record also stops the workflow before a report is written. npm run validate checks the whitespace-normalisation boundary, the output-path default, and representative status-code failures.
Learning Boundaries
The project uses async filesystem methods only because file reads and writes are the subject of Chapter 5. It does not teach concurrency, retries, timeouts, advanced error classification, test-framework design, CI/CD, live API calls, or secret-management products. Those concerns are addressed in later parts of the handbook.