UNPKG

playwright-bdd

Version:
29 lines 1.17 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.buildException = buildException; const stripAnsiEscapes_1 = require("../../../utils/stripAnsiEscapes"); function buildException(error) { const messageWithSnippet = getMessageWithSnippet(error); const stack = getStackTrace(error); const fullMessage = [messageWithSnippet, stack].filter(Boolean).join('\n\n'); return { type: 'Error', message: messageWithSnippet, stackTrace: fullMessage, }; } function getMessageWithSnippet(error) { const message = error.message ? (0, stripAnsiEscapes_1.stripAnsiEscapes)(error.message).trim() : String(error); const snippet = error.snippet ? (0, stripAnsiEscapes_1.stripAnsiEscapes)(error.snippet) : ''; return [message, snippet].filter(Boolean).join('\n\n'); } function getStackTrace(error) { return error.stack ? extractStackTrace((0, stripAnsiEscapes_1.stripAnsiEscapes)(error.stack)) : ''; } function extractStackTrace(errorStack) { return errorStack .split('\n') .filter((line) => line.match(/^\s+at .*/)) .join('\n'); } //# sourceMappingURL=Exception.js.map