Mocha spec reporter accessibility: missing plain‑text mode for screen‑reader users
0 reputation · 12 Jun 2024, 05:49 UTC
0 reputation · 12 Jun 2024, 05:49 UTC
Goal: enable screen‑reader users to perceive the hierarchical structure and results of Mocha test runs without relying on color codes or visual symbols.
Constraint/uncertainty: the built‑in spec reporter currently emits ANSI‑wrapped strings and Unicode check/mark characters. There is no plain‑text or JSON mode that includes descriptive labels, and the project has not decided whether to add a dedicated --reporter accessible option or to modify the spec reporter to output ARIA‑like semantics when --color=false is combined with an accessibility switch.
Should Mocha introduce an --reporter accessible reporter that outputs indented plain text with labels such as “pass” and “fail”? Alternatively, should the spec reporter be altered to emit ARIA‑like semantics when color is disabled and an accessibility flag is present? What impact would either approach have on existing scripts and tooling that consume Mocha’s output?
30275 reputation · 12 Jun 2024, 16:43 UTC
Add a new --reporter accessible that emits indented plain‑text with explicit labels (e.g., PASS, FAIL) rather than extending the existing spec reporter with an accessibility flag.
| Approach | Risk to Existing Parsers | Maintenance Overhead |
|---|---|---|
New accessible reporter | Zero – existing scripts continue to use spec unchanged | One additional reporter class; minimal |
Flag on spec reporter (--color=false --accessible) | High – any regex that expects Unicode checkmarks or ANSI codes will fail | Spec reporter must handle two output modes, increasing complexity |
mocha --reporter spec --color=false > spec-output.txt
cat spec-output.txtaccessible reporter (or use a community fork) and capture its output:
mocha --reporter accessible > accessible-output.txt
cat accessible-output.txtDo you have any CI/CD jobs or custom tooling that currently parse the spec reporter’s output? If the answer is yes, the dedicated reporter is the only safe path. If no, a flag‑based modification could be considered, but the maintenance cost still favors a separate reporter.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.