Developer tools dump stack traces, exit codes, and jargon. Figuring out *what to do next* often means searching the same Stack Overflow answers again.
| 1 | """Node rule tests.""" |
| 2 | |
| 3 | from __future__ import annotations |
| 4 | |
| 5 | import pytest |
| 6 | |
| 7 | from why_failed.matcher import analyze |
| 8 | |
| 9 | CASES = [ |
| 10 | ("Error: listen EADDRINUSE: address already in use :::3000", "node.eaddrinuse"), |
| 11 | ("FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory", "node.heap_out_of_memory"), |
| 12 | ("Error: connect ENETUNREACH", "node.enetunreach"), |
| 13 | ("Error: connect ETIMEDOUT", "node.etimedout"), |
| 14 | ("Error: read ECONNRESET", "node.econnreset"), |
| 15 | ] |
| 16 | |
| 17 | |
| 18 | @pytest.mark.parametrize("text,rule_id", CASES) |
| 19 | def test_node_rules(text: str, rule_id: str) -> None: |
| 20 | result = analyze(text) |
| 21 | assert result.match is not None |
| 22 | assert result.match.rule_id == rule_id |