(output)
| 226 | } |
| 227 | |
| 228 | function parseMocha(output) { |
| 229 | const result = { passed: 0, failed: 0, errors: 0, skipped: 0, failures: [] }; |
| 230 | |
| 231 | const passingLine = output.match(/(\d+) passing/); if (passingLine) result.passed = parseInt(passingLine[1], 10); |
| 232 | const failingLine = output.match(/(\d+) failing/); if (failingLine) result.failed = parseInt(failingLine[1], 10); |
| 233 | const pendingLine = output.match(/(\d+) pending/); if (pendingLine) result.skipped = parseInt(pendingLine[1], 10); |
| 234 | |
| 235 | // " N) test suite title:" |
| 236 | const failHeaderRe = /^\s+\d+\)\s+(.+):?\s*$/mg; |
| 237 | let m; |
| 238 | while ((m = failHeaderRe.exec(output)) !== null) { |
| 239 | // Next non-empty line is usually the error message |
| 240 | const rest = output.slice(m.index + m[0].length); |
| 241 | const msgLine = rest.split('\n').find(l => l.trim().length > 0); |
| 242 | result.failures.push({ name: m[1].trim(), message: (msgLine || '').trim().slice(0, 200) }); |
| 243 | } |
| 244 | |
| 245 | return result; |
| 246 | } |
| 247 | |
| 248 | function parseNodeTest(output) { |
| 249 | // TAP-like output from node:test |
no outgoing calls
no test coverage detected