UNPKG

@serenity-js/playwright-test

Version:

Serenity/JS test runner adapter for Playwright Test, combining Playwright's developer experience with the advanced reporting and automation capabilities of Serenity/JS

28 lines 1.27 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.PlaywrightErrorParser = void 0; class PlaywrightErrorParser { static ascii = new RegExp('[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:[a-zA-Z\\d]*(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)|(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))', // eslint-disable-line no-control-regex 'g'); errorFrom(testError) { const message = testError.message && PlaywrightErrorParser.stripAsciiFrom(testError.message); let stack = testError.stack && PlaywrightErrorParser.stripAsciiFrom(testError.stack); // TODO: Do I need to process it? // const value = testError.value; const prologue = `Error: ${message}`; if (stack && message && stack.startsWith(prologue)) { stack = stack.slice(prologue.length); } if (testError.cause) { stack += `\nCaused by: ${this.errorFrom(testError.cause).stack}`; } const error = new Error(message); error.stack = stack; return error; } static stripAsciiFrom(text) { return text.replace(this.ascii, ''); } } exports.PlaywrightErrorParser = PlaywrightErrorParser; //# sourceMappingURL=PlaywrightErrorParser.js.map