(logs, type = ['error'])
| 127 | } |
| 128 | |
| 129 | function getBrowserErrors(logs, type = ['error']) { |
| 130 | // Accepts Playwright ConsoleMessage objects, normalized {type, text}, or strings |
| 131 | return logs |
| 132 | .map(log => { |
| 133 | if (typeof log === 'string') return log |
| 134 | if (!log) return null |
| 135 | const t = typeof log.type === 'function' ? log.type() : log.type |
| 136 | const text = typeof log.text === 'function' ? log.text() : log.text |
| 137 | if (!t) return null |
| 138 | return { type: t, text } |
| 139 | }) |
| 140 | .filter(l => l && (typeof l === 'string' || type.includes(l.type))) |
| 141 | .map(l => (typeof l === 'string' ? l : l.text)) |
| 142 | } |
no test coverage detected