From fcd4abbca6238bec3694ba61bb4a6306dd02c779 Mon Sep 17 00:00:00 2001 From: Blake Vandercar Date: Tue, 5 Nov 2024 22:25:19 -0700 Subject: [PATCH 01/22] feat: consoleProcessor accomodate message markdown --- src/outputProcessor/consoleProcessor.ts | 9 ++++++++- src/utils.ts | 23 ++++++++++++++++++++++- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/src/outputProcessor/consoleProcessor.ts b/src/outputProcessor/consoleProcessor.ts index f692382..1e67bc8 100644 --- a/src/outputProcessor/consoleProcessor.ts +++ b/src/outputProcessor/consoleProcessor.ts @@ -2,6 +2,7 @@ import CONSTANTS from "../constants"; import type {Log, LogType, MessageData} from "../types"; import type {PluginOptions} from "../installLogsPrinter.types"; import chalk from "chalk"; +import utils from "utils"; const LOG_TYPES = CONSTANTS.LOG_TYPES; const KNOWN_TYPES = Object.values(CONSTANTS.LOG_TYPES); @@ -127,7 +128,7 @@ function consoleProcessor( severity, timeString }) => { - let processedMessage = message; + let {isItalic, isBold, processedMessage} = utils.checkMessageMarkdown(message); let {color, icon, trim} = TYPE_COMPUTE[type](options); trim = trim || options.defaultTrimLength || 800; @@ -143,6 +144,12 @@ function consoleProcessor( if (message.length > trim) { processedMessage = message.substring(0, trim) + ' ...'; } + if (isItalic) { + processedMessage = chalk.italic(processedMessage) + } + if (isBold) { + processedMessage = chalk.bold(processedMessage) + } if (timeString) { output += chalk.gray(`${padding}Time: ${timeString}`) + '\n'; diff --git a/src/utils.ts b/src/utils.ts index 31b8b8d..8951461 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -82,10 +82,31 @@ const utils = { return json; }, - validatorErrToStr: function (errorList: Failure[]) { + validatorErrToStr(errorList: Failure[]) { return '\n' + errorList.map((error) => { return ` => ${error.path.join('.')}: ${error.message}`; }).join('\n') + '\n'; + }, + + /** + * The Cypress GUI runner allows markdown in `cy.log` messages. We can take this + * into account for our loggers as well. + */ + checkMessageMarkdown(message: string) { + let processedMessage = message + const isItalic = message.startsWith('_') && message.endsWith('_') + const isBold = message.startsWith('**') && message.endsWith('**') + + // TODO: account for both bold and italic? + if (isItalic) { + processedMessage = processedMessage.replace(/^_*/,"").replace(/_*$/,"") + } + + if (isBold) { + processedMessage = processedMessage.replace(/^(\*\*)*/,"").replace(/(\*\*)*$/,"") + } + + return {isItalic, isBold, processedMessage} } } From 0351f27da02a061d6845fde76af196ef1e3948c5 Mon Sep 17 00:00:00 2001 From: Blake Vandercar Date: Tue, 5 Nov 2024 22:26:33 -0700 Subject: [PATCH 02/22] fix import --- src/outputProcessor/consoleProcessor.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/outputProcessor/consoleProcessor.ts b/src/outputProcessor/consoleProcessor.ts index 1e67bc8..ac5c806 100644 --- a/src/outputProcessor/consoleProcessor.ts +++ b/src/outputProcessor/consoleProcessor.ts @@ -1,8 +1,8 @@ import CONSTANTS from "../constants"; import type {Log, LogType, MessageData} from "../types"; +import utils from "../utils"; import type {PluginOptions} from "../installLogsPrinter.types"; import chalk from "chalk"; -import utils from "utils"; const LOG_TYPES = CONSTANTS.LOG_TYPES; const KNOWN_TYPES = Object.values(CONSTANTS.LOG_TYPES); From 2341910ccfed6282011488512f83d27658cfee9d Mon Sep 17 00:00:00 2001 From: Blake Vandercar Date: Wed, 6 Nov 2024 10:11:29 -0700 Subject: [PATCH 03/22] add color option, add unit tests --- src/outputProcessor/consoleProcessor.ts | 15 ++++++++---- src/utils.ts | 31 +++++++++++++++---------- test/specs/utils.spec.js | 30 ++++++++++++++++++++++++ 3 files changed, 60 insertions(+), 16 deletions(-) create mode 100644 test/specs/utils.spec.js diff --git a/src/outputProcessor/consoleProcessor.ts b/src/outputProcessor/consoleProcessor.ts index ac5c806..6c7dc38 100644 --- a/src/outputProcessor/consoleProcessor.ts +++ b/src/outputProcessor/consoleProcessor.ts @@ -128,8 +128,8 @@ function consoleProcessor( severity, timeString }) => { - let {isItalic, isBold, processedMessage} = utils.checkMessageMarkdown(message); - + let {isItalic, isBold, color: messageColor, processedMessage} = utils.checkMessageMarkdown(message); + let {color, icon, trim} = TYPE_COMPUTE[type](options); trim = trim || options.defaultTrimLength || 800; @@ -141,8 +141,8 @@ function consoleProcessor( icon = LOG_SYMBOLS.warning; } - if (message.length > trim) { - processedMessage = message.substring(0, trim) + ' ...'; + if (processedMessage.length > trim) { + processedMessage = processedMessage.substring(0, trim) + ' ...'; } if (isItalic) { processedMessage = chalk.italic(processedMessage) @@ -150,6 +150,13 @@ function consoleProcessor( if (isBold) { processedMessage = chalk.bold(processedMessage) } + if (messageColor) { + try { + processedMessage = chalk.keyword(messageColor)(processedMessage) + } + catch { + } + } if (timeString) { output += chalk.gray(`${padding}Time: ${timeString}`) + '\n'; diff --git a/src/utils.ts b/src/utils.ts index 8951461..4991a51 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -91,22 +91,29 @@ const utils = { /** * The Cypress GUI runner allows markdown in `cy.log` messages. We can take this * into account for our loggers as well. + * - italic: _text_ + * - bold: **text** + * - colored: [color](text) + * https://github.com/cypress-io/cypress-documentation/issues/778 */ checkMessageMarkdown(message: string) { - let processedMessage = message - const isItalic = message.startsWith('_') && message.endsWith('_') - const isBold = message.startsWith('**') && message.endsWith('**') - - // TODO: account for both bold and italic? - if (isItalic) { - processedMessage = processedMessage.replace(/^_*/,"").replace(/_*$/,"") - } - - if (isBold) { - processedMessage = processedMessage.replace(/^(\*\*)*/,"").replace(/(\*\*)*$/,"") + const coloredMarkup = message.match(/^\[(.*)\]\((.*)\)/) // ie [blue](http://example.com) + const color = coloredMarkup?.at(1) + const coloredMessage = coloredMarkup?.at(2) + if (coloredMessage) { + message = coloredMessage } - return {isItalic, isBold, processedMessage} + const italicMatch = message.match(/^_(.*?)_$/); // ie _italic_ + const isItalic = Boolean(italicMatch) + message = italicMatch?.at(1) ?? message; + + const boldMatch = message.match(/^\*\*(.*?)\*\*$/); // ie **bold** + const isBold = Boolean(boldMatch) + message = boldMatch?.at(1) ?? message; + + // TODO: account for both bold and italic? + return { isItalic, isBold, color, processedMessage: message } } } diff --git a/test/specs/utils.spec.js b/test/specs/utils.spec.js new file mode 100644 index 0000000..d118f89 --- /dev/null +++ b/test/specs/utils.spec.js @@ -0,0 +1,30 @@ +const utils = require('../../src/utils').default +const {expect} = require('chai'); + +const {checkMessageMarkdown} = utils + +describe('utils', () => { + describe('checkMessageMarkdown', () => { + it('correctly detects cypress log message markdown and returns processed message with markdown removed', () => { + const tests = [ + {message: '_text text_text_', isItalic: true, processedMessage: 'text text_text'}, + {message: '_text _text'}, + {message: 'text text_'}, + {message: '**text **text**', isBold: true, processedMessage: 'text **text'}, + {message: '*text text**'}, + {message: '**text text*'}, + {message: '*text text*'}, + {message: '[blue](text text)', color: 'blue', processedMessage: 'text text'}, + ] + tests.forEach(({message, ...expected}) => { + expect(checkMessageMarkdown(message)).to.deep.equal({ + color: undefined, + isItalic: false, + isBold: false, + processedMessage: message, + ...expected + }) + }) + }) + }) +}) \ No newline at end of file From e058c2e996d8abd25bbd176a878612a8afd2d422 Mon Sep 17 00:00:00 2001 From: Blake Vandercar Date: Wed, 6 Nov 2024 10:49:10 -0700 Subject: [PATCH 04/22] don't use .at (old node version) --- src/utils.ts | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/src/utils.ts b/src/utils.ts index 4991a51..982315b 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -97,23 +97,30 @@ const utils = { * https://github.com/cypress-io/cypress-documentation/issues/778 */ checkMessageMarkdown(message: string) { - const coloredMarkup = message.match(/^\[(.*)\]\((.*)\)/) // ie [blue](http://example.com) - const color = coloredMarkup?.at(1) - const coloredMessage = coloredMarkup?.at(2) - if (coloredMessage) { - message = coloredMessage + const colorMatch = message.match(/^\[(.*)\]\((.*)\)/) // ie [blue](http://example.com) + let color: string | undefined = undefined; + if (colorMatch) { + color = colorMatch[1] + message = colorMatch[2] } const italicMatch = message.match(/^_(.*?)_$/); // ie _italic_ - const isItalic = Boolean(italicMatch) - message = italicMatch?.at(1) ?? message; + if (italicMatch) { + message = italicMatch[1] + } const boldMatch = message.match(/^\*\*(.*?)\*\*$/); // ie **bold** - const isBold = Boolean(boldMatch) - message = boldMatch?.at(1) ?? message; + if (boldMatch) { + message = boldMatch[1] + } // TODO: account for both bold and italic? - return { isItalic, isBold, color, processedMessage: message } + return { + isItalic: Boolean(italicMatch), + isBold: Boolean(boldMatch), + color, + processedMessage: message + } } } From 83d13d37968662b332c261bff8795548c6d456ad Mon Sep 17 00:00:00 2001 From: Blake Vandercar Date: Wed, 6 Nov 2024 10:57:58 -0700 Subject: [PATCH 05/22] remove chalk.keyword --- src/outputProcessor/consoleProcessor.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/outputProcessor/consoleProcessor.ts b/src/outputProcessor/consoleProcessor.ts index 6c7dc38..00b3288 100644 --- a/src/outputProcessor/consoleProcessor.ts +++ b/src/outputProcessor/consoleProcessor.ts @@ -152,7 +152,7 @@ function consoleProcessor( } if (messageColor) { try { - processedMessage = chalk.keyword(messageColor)(processedMessage) + processedMessage = chalk[messageColor as "red"]?.(processedMessage) } catch { } From b3dec9736a6f2a08c85ce5497eebffb575ee88d5 Mon Sep 17 00:00:00 2001 From: Blake Vandercar Date: Wed, 6 Nov 2024 11:11:36 -0700 Subject: [PATCH 06/22] ws --- test/specs/utils.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/specs/utils.spec.js b/test/specs/utils.spec.js index d118f89..0de34fe 100644 --- a/test/specs/utils.spec.js +++ b/test/specs/utils.spec.js @@ -19,7 +19,7 @@ describe('utils', () => { tests.forEach(({message, ...expected}) => { expect(checkMessageMarkdown(message)).to.deep.equal({ color: undefined, - isItalic: false, + isItalic: false, isBold: false, processedMessage: message, ...expected From 470bc359c97b02744cbecee4e3e3c177a90483c8 Mon Sep 17 00:00:00 2001 From: Blake Vandercar Date: Wed, 6 Nov 2024 11:41:57 -0700 Subject: [PATCH 07/22] refactor: use import --- test/specs/utils.spec.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/specs/utils.spec.js b/test/specs/utils.spec.js index 0de34fe..1dc1526 100644 --- a/test/specs/utils.spec.js +++ b/test/specs/utils.spec.js @@ -1,5 +1,5 @@ -const utils = require('../../src/utils').default -const {expect} = require('chai'); +import utils from '../../src/utils' +import {expect} from 'chai' const {checkMessageMarkdown} = utils From f81bcc6414e5704c74cd39ccd4ccbd36a50fd02b Mon Sep 17 00:00:00 2001 From: Blake Vandercar Date: Tue, 12 Nov 2024 13:15:31 -0700 Subject: [PATCH 08/22] update tests --- package-lock.json | 4 ++-- src/outputProcessor/consoleProcessor.ts | 5 ++++- test/specs/utils.spec.js | 2 ++ 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 2b29c25..82ae5da 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "cypress-terminal-report", - "version": "7.0.2", + "version": "7.0.4", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "cypress-terminal-report", - "version": "7.0.2", + "version": "7.0.4", "license": "MIT", "dependencies": { "chalk": "^4.0.0", diff --git a/src/outputProcessor/consoleProcessor.ts b/src/outputProcessor/consoleProcessor.ts index 00b3288..9a8e40d 100644 --- a/src/outputProcessor/consoleProcessor.ts +++ b/src/outputProcessor/consoleProcessor.ts @@ -152,7 +152,10 @@ function consoleProcessor( } if (messageColor) { try { - processedMessage = chalk[messageColor as "red"]?.(processedMessage) + const colorFunction = chalk[messageColor as keyof typeof chalk] + if (colorFunction === chalk) { + processedMessage = colorFunction(processedMessage) + } } catch { } diff --git a/test/specs/utils.spec.js b/test/specs/utils.spec.js index 1dc1526..da87f71 100644 --- a/test/specs/utils.spec.js +++ b/test/specs/utils.spec.js @@ -15,6 +15,8 @@ describe('utils', () => { {message: '**text text*'}, {message: '*text text*'}, {message: '[blue](text text)', color: 'blue', processedMessage: 'text text'}, + {message: '[orange](text text)', color: 'orange', processedMessage: 'text text'}, + {message: '[noncolor](text text)', processedMessage: 'text text'}, ] tests.forEach(({message, ...expected}) => { expect(checkMessageMarkdown(message)).to.deep.equal({ From 99525510f166ec40d880d0120c9e20b9b57727e8 Mon Sep 17 00:00:00 2001 From: Blake Vandercar Date: Tue, 12 Nov 2024 13:33:13 -0700 Subject: [PATCH 09/22] revert --- test/specs/utils.spec.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/test/specs/utils.spec.js b/test/specs/utils.spec.js index da87f71..1dc1526 100644 --- a/test/specs/utils.spec.js +++ b/test/specs/utils.spec.js @@ -15,8 +15,6 @@ describe('utils', () => { {message: '**text text*'}, {message: '*text text*'}, {message: '[blue](text text)', color: 'blue', processedMessage: 'text text'}, - {message: '[orange](text text)', color: 'orange', processedMessage: 'text text'}, - {message: '[noncolor](text text)', processedMessage: 'text text'}, ] tests.forEach(({message, ...expected}) => { expect(checkMessageMarkdown(message)).to.deep.equal({ From 15a39dca6c9062c4bd48b78d7a3c06f0564c231a Mon Sep 17 00:00:00 2001 From: Blake Vandercar Date: Tue, 12 Nov 2024 18:37:17 -0700 Subject: [PATCH 10/22] only checkMessageMarkdown if cy:log --- src/outputProcessor/consoleProcessor.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/outputProcessor/consoleProcessor.ts b/src/outputProcessor/consoleProcessor.ts index 9a8e40d..9349bcf 100644 --- a/src/outputProcessor/consoleProcessor.ts +++ b/src/outputProcessor/consoleProcessor.ts @@ -128,10 +128,11 @@ function consoleProcessor( severity, timeString }) => { - let {isItalic, isBold, color: messageColor, processedMessage} = utils.checkMessageMarkdown(message); - - let {color, icon, trim} = TYPE_COMPUTE[type](options); - trim = trim || options.defaultTrimLength || 800; + let {isItalic = false, + isBold = false, + color: messageColor = undefined, + processedMessage = message} = type == "cy:log" ? utils.checkMessageMarkdown(message) : {}; + let {color, icon, trim = options.defaultTrimLength || 800} = TYPE_COMPUTE[type](options); if (severity === CONSTANTS.SEVERITY.ERROR) { color = 'red'; From 103b9b4d4cb88140d03c303f259eb5557e680571 Mon Sep 17 00:00:00 2001 From: Blake Vandercar Date: Wed, 13 Nov 2024 10:58:22 -0700 Subject: [PATCH 11/22] refactor: better regex --- src/outputProcessor/consoleProcessor.ts | 36 +++++++++--------- src/utils.ts | 47 +++++++++++------------- test/specs/utils.spec.js | 49 ++++++++++++++----------- 3 files changed, 66 insertions(+), 66 deletions(-) diff --git a/src/outputProcessor/consoleProcessor.ts b/src/outputProcessor/consoleProcessor.ts index 9349bcf..7a42d28 100644 --- a/src/outputProcessor/consoleProcessor.ts +++ b/src/outputProcessor/consoleProcessor.ts @@ -128,10 +128,7 @@ function consoleProcessor( severity, timeString }) => { - let {isItalic = false, - isBold = false, - color: messageColor = undefined, - processedMessage = message} = type == "cy:log" ? utils.checkMessageMarkdown(message) : {}; + let processedMessage = message let {color, icon, trim = options.defaultTrimLength || 800} = TYPE_COMPUTE[type](options); if (severity === CONSTANTS.SEVERITY.ERROR) { @@ -142,24 +139,25 @@ function consoleProcessor( icon = LOG_SYMBOLS.warning; } - if (processedMessage.length > trim) { + if (message.length > trim) { processedMessage = processedMessage.substring(0, trim) + ' ...'; } - if (isItalic) { - processedMessage = chalk.italic(processedMessage) - } - if (isBold) { - processedMessage = chalk.bold(processedMessage) - } - if (messageColor) { - try { - const colorFunction = chalk[messageColor as keyof typeof chalk] - if (colorFunction === chalk) { - processedMessage = colorFunction(processedMessage) + + if (type == "cy:log") { + processedMessage = utils.applyMessageMarkdown(processedMessage, { + bold: chalk.bold, + italic: chalk.italic, + color: (str, color) => { + try { + const colorFunction = chalk[color as keyof typeof chalk] + if (colorFunction === chalk) { + return colorFunction(str) + } + } + catch {/* noop */ } + return str } - } - catch { - } + }) } if (timeString) { diff --git a/src/utils.ts b/src/utils.ts index 982315b..da2af16 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -91,36 +91,33 @@ const utils = { /** * The Cypress GUI runner allows markdown in `cy.log` messages. We can take this * into account for our loggers as well. - * - italic: _text_ - * - bold: **text** - * - colored: [color](text) - * https://github.com/cypress-io/cypress-documentation/issues/778 */ - checkMessageMarkdown(message: string) { - const colorMatch = message.match(/^\[(.*)\]\((.*)\)/) // ie [blue](http://example.com) - let color: string | undefined = undefined; - if (colorMatch) { - color = colorMatch[1] - message = colorMatch[2] - } + applyMessageMarkdown(message: string, {bold, italic, color}: { + bold: (str: string) => string, + italic: (str: string) => string, + color?: (str: string, color: string) => string + }) { + // Markdown regex: https://gist.github.com/elfefe/ef08e583e276e7617cd316ba2382fc40 - const italicMatch = message.match(/^_(.*?)_$/); // ie _italic_ - if (italicMatch) { - message = italicMatch[1] - } + // bold and italic, i.e. ***text*** or ___text___ + message = message.replace(new RegExp(/\*\*\*(.+?)\*\*\*|___(.+?)___/), + (str, group1, group2) => bold(italic(group1 || group2))) - const boldMatch = message.match(/^\*\*(.*?)\*\*$/); // ie **bold** - if (boldMatch) { - message = boldMatch[1] - } + // bold, i.e. **text** or __text__ + message = message.replace(new RegExp(/\*\*(.+?)\*\*|__(.+?)__/), + (str, group1, group2) => bold(group1 || group2)) - // TODO: account for both bold and italic? - return { - isItalic: Boolean(italicMatch), - isBold: Boolean(boldMatch), - color, - processedMessage: message + // italic, i.e. *text* or _text_ + message = message.replace(new RegExp(/\*(.+?)\*|_(.+?)_/), + (str, group1, group2) => italic(group1 || group2)) + + if (color) { + // colored, i.e. [blue](http://example.com) + message = message.replace(new RegExp(/\[(.*)\]\((.*)\)/), + (str, group1: string, group2: string) => color(group2, group1)) } + + return message } } diff --git a/test/specs/utils.spec.js b/test/specs/utils.spec.js index 1dc1526..191ad8f 100644 --- a/test/specs/utils.spec.js +++ b/test/specs/utils.spec.js @@ -1,30 +1,35 @@ import utils from '../../src/utils' import {expect} from 'chai' -const {checkMessageMarkdown} = utils +const {applyMessageMarkdown} = utils describe('utils', () => { - describe('checkMessageMarkdown', () => { - it('correctly detects cypress log message markdown and returns processed message with markdown removed', () => { + describe('applyMessageMarkdown', () => { + it('correctly detects markdown and returns processed message with functions applied', () => { const tests = [ - {message: '_text text_text_', isItalic: true, processedMessage: 'text text_text'}, - {message: '_text _text'}, - {message: 'text text_'}, - {message: '**text **text**', isBold: true, processedMessage: 'text **text'}, - {message: '*text text**'}, - {message: '**text text*'}, - {message: '*text text*'}, - {message: '[blue](text text)', color: 'blue', processedMessage: 'text text'}, + ['*text text*', 'Itext textI'], + ['_text text_', 'Itext textI'], + ['**text text**', 'Btext textB'], + ['__text text__', 'Btext textB'], + ['***text text***', 'BItext textIB'], + ['___text text___', 'BItext textIB'], + ['__*text text*__', 'BItext textIB'], + ['*__text text__*', 'IBtext textBI'], + ['_text text_text_', 'Itext textItext_'], + ['text text_','text text_'], + ['**text **text**', 'Btext Btext**'], + ['*text text**', 'Itext textI*'], + ['**text text*', 'I*text textI'], + ['[blue](text text)', 'text text<>'], + ['[blue](*text text*)', 'Itext textI<>'], ] - tests.forEach(({message, ...expected}) => { - expect(checkMessageMarkdown(message)).to.deep.equal({ - color: undefined, - isItalic: false, - isBold: false, - processedMessage: message, - ...expected - }) - }) - }) - }) + tests.forEach(([message, expected]) => { + expect(applyMessageMarkdown(message, { + bold: (str) => `B${str}B`, + italic: (str) => `I${str}I`, + color: (str, color) => `<${color}>${str}<>` + })).to.deep.equal(expected) + }) + }) + }) }) \ No newline at end of file From 591c3303b058ef70514e4e061513b550b5b959d3 Mon Sep 17 00:00:00 2001 From: Blake Vandercar Date: Wed, 13 Nov 2024 11:01:04 -0700 Subject: [PATCH 12/22] imrpoved test --- test/specs/utils.spec.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/specs/utils.spec.js b/test/specs/utils.spec.js index 191ad8f..f29b6e1 100644 --- a/test/specs/utils.spec.js +++ b/test/specs/utils.spec.js @@ -15,6 +15,8 @@ describe('utils', () => { ['___text text___', 'BItext textIB'], ['__*text text*__', 'BItext textIB'], ['*__text text__*', 'IBtext textBI'], + ['text text __text text__', 'text text Btext textB'], + ['_text text_ __text text__', 'Itext textI Btext textB'], ['_text text_text_', 'Itext textItext_'], ['text text_','text text_'], ['**text **text**', 'Btext Btext**'], From 2a4a98ea895dcc77856344e887eae2a12fab82e4 Mon Sep 17 00:00:00 2001 From: Blake Vandercar Date: Wed, 13 Nov 2024 11:02:00 -0700 Subject: [PATCH 13/22] revert --- src/outputProcessor/consoleProcessor.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/outputProcessor/consoleProcessor.ts b/src/outputProcessor/consoleProcessor.ts index 7a42d28..8c81247 100644 --- a/src/outputProcessor/consoleProcessor.ts +++ b/src/outputProcessor/consoleProcessor.ts @@ -128,7 +128,7 @@ function consoleProcessor( severity, timeString }) => { - let processedMessage = message + let processedMessage = message; let {color, icon, trim = options.defaultTrimLength || 800} = TYPE_COMPUTE[type](options); if (severity === CONSTANTS.SEVERITY.ERROR) { @@ -140,7 +140,7 @@ function consoleProcessor( } if (message.length > trim) { - processedMessage = processedMessage.substring(0, trim) + ' ...'; + processedMessage = message.substring(0, trim) + ' ...'; } if (type == "cy:log") { From 30cec0af8b9ee0d5e96e48d6cf1facf292b4d279 Mon Sep 17 00:00:00 2001 From: Blake Vandercar Date: Wed, 13 Nov 2024 11:30:16 -0700 Subject: [PATCH 14/22] ignore escape --- src/outputProcessor/consoleProcessor.ts | 2 +- src/utils.ts | 30 ++++++++++++++++++------- test/specs/utils.spec.js | 2 +- 3 files changed, 24 insertions(+), 10 deletions(-) diff --git a/src/outputProcessor/consoleProcessor.ts b/src/outputProcessor/consoleProcessor.ts index 8c81247..453220f 100644 --- a/src/outputProcessor/consoleProcessor.ts +++ b/src/outputProcessor/consoleProcessor.ts @@ -147,7 +147,7 @@ function consoleProcessor( processedMessage = utils.applyMessageMarkdown(processedMessage, { bold: chalk.bold, italic: chalk.italic, - color: (str, color) => { + colored: (str, color) => { try { const colorFunction = chalk[color as keyof typeof chalk] if (colorFunction === chalk) { diff --git a/src/utils.ts b/src/utils.ts index da2af16..128346c 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -2,6 +2,20 @@ import jsonPrune from "./jsonPrune"; import {compare} from "compare-versions"; import {Failure} from "superstruct"; +function getMarkdownRegex(numWrapperChars:number){ + // allow for escape characters + const asteriskWrapper=`(?:(?) => { if (Cypress.testingType === 'component' && compare(Cypress.version, '12.15.0', '>=')) { @@ -92,29 +106,29 @@ const utils = { * The Cypress GUI runner allows markdown in `cy.log` messages. We can take this * into account for our loggers as well. */ - applyMessageMarkdown(message: string, {bold, italic, color}: { + applyMessageMarkdown(message: string, {bold, italic, colored}: { bold: (str: string) => string, italic: (str: string) => string, - color?: (str: string, color: string) => string + colored?: (str: string, color: string) => string }) { // Markdown regex: https://gist.github.com/elfefe/ef08e583e276e7617cd316ba2382fc40 // bold and italic, i.e. ***text*** or ___text___ - message = message.replace(new RegExp(/\*\*\*(.+?)\*\*\*|___(.+?)___/), + message = message.replace(MARKDOWN_REGEX.BOLD_AND_ITALIC, (str, group1, group2) => bold(italic(group1 || group2))) // bold, i.e. **text** or __text__ - message = message.replace(new RegExp(/\*\*(.+?)\*\*|__(.+?)__/), + message = message.replace(MARKDOWN_REGEX.BOLD, (str, group1, group2) => bold(group1 || group2)) // italic, i.e. *text* or _text_ - message = message.replace(new RegExp(/\*(.+?)\*|_(.+?)_/), + message = message.replace(MARKDOWN_REGEX.ITALIC, (str, group1, group2) => italic(group1 || group2)) - if (color) { + if (colored) { // colored, i.e. [blue](http://example.com) - message = message.replace(new RegExp(/\[(.*)\]\((.*)\)/), - (str, group1: string, group2: string) => color(group2, group1)) + message = message.replace(MARKDOWN_REGEX.COLORED, + (str, group1: string, group2: string) => colored(group2, group1)) } return message diff --git a/test/specs/utils.spec.js b/test/specs/utils.spec.js index f29b6e1..9717391 100644 --- a/test/specs/utils.spec.js +++ b/test/specs/utils.spec.js @@ -29,7 +29,7 @@ describe('utils', () => { expect(applyMessageMarkdown(message, { bold: (str) => `B${str}B`, italic: (str) => `I${str}I`, - color: (str, color) => `<${color}>${str}<>` + colored: (str, color) => `<${color}>${str}<>` })).to.deep.equal(expected) }) }) From 7a955d3cf98ebbc20edccd15a4950d80eb8e9163 Mon Sep 17 00:00:00 2001 From: Blake Vandercar Date: Wed, 13 Nov 2024 13:57:55 -0700 Subject: [PATCH 15/22] refactor markdown --- src/outputProcessor/consoleProcessor.ts | 18 ++++-------- src/utils.ts | 38 ++++++++++++------------- test/specs/utils.spec.js | 14 ++------- 3 files changed, 26 insertions(+), 44 deletions(-) diff --git a/src/outputProcessor/consoleProcessor.ts b/src/outputProcessor/consoleProcessor.ts index 453220f..4b1726d 100644 --- a/src/outputProcessor/consoleProcessor.ts +++ b/src/outputProcessor/consoleProcessor.ts @@ -139,25 +139,17 @@ function consoleProcessor( icon = LOG_SYMBOLS.warning; } - if (message.length > trim) { - processedMessage = message.substring(0, trim) + ' ...'; - } + const maybeTrimLength = (msg: string) => msg.length > trim ? + (msg.substring(0, trim) + ' ...') : msg if (type == "cy:log") { processedMessage = utils.applyMessageMarkdown(processedMessage, { bold: chalk.bold, italic: chalk.italic, - colored: (str, color) => { - try { - const colorFunction = chalk[color as keyof typeof chalk] - if (colorFunction === chalk) { - return colorFunction(str) - } - } - catch {/* noop */ } - return str - } + processContents: maybeTrimLength }) + } else { + processedMessage = maybeTrimLength(processedMessage) } if (timeString) { diff --git a/src/utils.ts b/src/utils.ts index 128346c..e223ad9 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -2,18 +2,17 @@ import jsonPrune from "./jsonPrune"; import {compare} from "compare-versions"; import {Failure} from "superstruct"; -function getMarkdownRegex(numWrapperChars:number){ - // allow for escape characters - const asteriskWrapper=`(?:(? string, italic: (str: string) => string, - colored?: (str: string, color: string) => string + processContents?: (str: string) => string }) { - // Markdown regex: https://gist.github.com/elfefe/ef08e583e276e7617cd316ba2382fc40 + let contentsHaveBeenProcessed = false + const maybeProcessContents = (str: string) => { + if (contentsHaveBeenProcessed || !processContents) return str + contentsHaveBeenProcessed = true + return processContents(str) + } // bold and italic, i.e. ***text*** or ___text___ message = message.replace(MARKDOWN_REGEX.BOLD_AND_ITALIC, - (str, group1, group2) => bold(italic(group1 || group2))) + (str, group1, group2) => bold(italic(maybeProcessContents(group1 || group2)))) // bold, i.e. **text** or __text__ message = message.replace(MARKDOWN_REGEX.BOLD, - (str, group1, group2) => bold(group1 || group2)) + (str, group1, group2) => bold(maybeProcessContents(group1 || group2))) // italic, i.e. *text* or _text_ message = message.replace(MARKDOWN_REGEX.ITALIC, - (str, group1, group2) => italic(group1 || group2)) - - if (colored) { - // colored, i.e. [blue](http://example.com) - message = message.replace(MARKDOWN_REGEX.COLORED, - (str, group1: string, group2: string) => colored(group2, group1)) - } + (str, group1, group2) => italic(maybeProcessContents(group1 || group2))) - return message + return maybeProcessContents(message) } } diff --git a/test/specs/utils.spec.js b/test/specs/utils.spec.js index 9717391..0773bea 100644 --- a/test/specs/utils.spec.js +++ b/test/specs/utils.spec.js @@ -13,24 +13,16 @@ describe('utils', () => { ['__text text__', 'Btext textB'], ['***text text***', 'BItext textIB'], ['___text text___', 'BItext textIB'], - ['__*text text*__', 'BItext textIB'], - ['*__text text__*', 'IBtext textBI'], - ['text text __text text__', 'text text Btext textB'], - ['_text text_ __text text__', 'Itext textI Btext textB'], - ['_text text_text_', 'Itext textItext_'], + ['_text text_text_', 'Itext text_textI'], ['text text_','text text_'], - ['**text **text**', 'Btext Btext**'], - ['*text text**', 'Itext textI*'], + ['*text text**', 'Itext text*I'], ['**text text*', 'I*text textI'], - ['[blue](text text)', 'text text<>'], - ['[blue](*text text*)', 'Itext textI<>'], ] tests.forEach(([message, expected]) => { expect(applyMessageMarkdown(message, { bold: (str) => `B${str}B`, italic: (str) => `I${str}I`, - colored: (str, color) => `<${color}>${str}<>` - })).to.deep.equal(expected) + }), message).to.deep.equal(expected) }) }) }) From 676e6ccec704f884eb8b3751fe103c394484e35f Mon Sep 17 00:00:00 2001 From: Blake Vandercar Date: Wed, 13 Nov 2024 14:07:03 -0700 Subject: [PATCH 16/22] add test --- test/specs/utils.spec.js | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/test/specs/utils.spec.js b/test/specs/utils.spec.js index 0773bea..ed50fa6 100644 --- a/test/specs/utils.spec.js +++ b/test/specs/utils.spec.js @@ -6,22 +6,26 @@ const {applyMessageMarkdown} = utils describe('utils', () => { describe('applyMessageMarkdown', () => { it('correctly detects markdown and returns processed message with functions applied', () => { + const LONG_MSG = "abc123".repeat(5) const tests = [ - ['*text text*', 'Itext textI'], - ['_text text_', 'Itext textI'], - ['**text text**', 'Btext textB'], - ['__text text__', 'Btext textB'], - ['***text text***', 'BItext textIB'], - ['___text text___', 'BItext textIB'], - ['_text text_text_', 'Itext text_textI'], + ['*text text*', 'text text'], + ['_text text_', 'text text'], + ['**text text**', 'text text'], + ['__text text__', 'text text'], + ['***text text***', 'text text'], + ['___text text___', 'text text'], + ['_text text_text_', 'text text_text'], ['text text_','text text_'], - ['*text text**', 'Itext text*I'], - ['**text text*', 'I*text textI'], + ['*text text','*text text'], + ['*text text**', 'text text*'], + ['**text text*', '*text text'], + [`**${LONG_MSG}**`, `${LONG_MSG.substring(0, 20)}...`], ] tests.forEach(([message, expected]) => { expect(applyMessageMarkdown(message, { - bold: (str) => `B${str}B`, - italic: (str) => `I${str}I`, + bold: (str) => `${str}`, + italic: (str) => `${str}`, + processContents: (c) => c.length > 20 ? (c.substring(0, 20) + '...') : c }), message).to.deep.equal(expected) }) }) From 4db1d541d1384ab4ac2d036382040dc98a9bf4e6 Mon Sep 17 00:00:00 2001 From: Blake Vandercar Date: Mon, 18 Nov 2024 09:01:06 -0700 Subject: [PATCH 17/22] run format --- src/outputProcessor/consoleProcessor.ts | 22 ++++---- src/utils.ts | 64 +++++++++++++---------- test/specs/utils.spec.js | 69 +++++++++++++------------ 3 files changed, 85 insertions(+), 70 deletions(-) diff --git a/src/outputProcessor/consoleProcessor.ts b/src/outputProcessor/consoleProcessor.ts index 9743990..88c73ab 100644 --- a/src/outputProcessor/consoleProcessor.ts +++ b/src/outputProcessor/consoleProcessor.ts @@ -1,8 +1,8 @@ -import CONSTANTS from "../constants"; -import type {Colors, Log, LogSymbols, LogType, MessageData} from "../types"; -import utils from "../utils"; -import type {PluginOptions} from "../installLogsPrinter.types"; -import chalk from "chalk"; +import CONSTANTS from '../constants'; +import type {Colors, Log, LogSymbols, LogType, MessageData} from '../types'; +import utils from '../utils'; +import type {PluginOptions} from '../installLogsPrinter.types'; +import chalk from 'chalk'; const {LOG_TYPES, COLORS} = CONSTANTS; const KNOWN_LOG_TYPES = Object.values(LOG_TYPES); @@ -121,17 +121,17 @@ function consoleProcessor(messages: Log[], options: PluginOptions, data: Message icon = LOG_SYMBOLS.WARNING; } - const maybeTrimLength = (msg: string) => msg.length > trim ? - (msg.substring(0, trim) + ' ...') : msg + const maybeTrimLength = (msg: string) => + msg.length > trim ? msg.substring(0, trim) + ' ...' : msg; - if (type == "cy:log") { + if (type == 'cy:log') { processedMessage = utils.applyMessageMarkdown(processedMessage, { bold: chalk.bold, italic: chalk.italic, - processContents: maybeTrimLength - }) + processContents: maybeTrimLength, + }); } else { - processedMessage = maybeTrimLength(processedMessage) + processedMessage = maybeTrimLength(processedMessage); } if (timeString) { diff --git a/src/utils.ts b/src/utils.ts index b320185..be9fdf7 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -4,16 +4,18 @@ import type {Failure} from 'superstruct'; // Markdown regex: https://gist.github.com/elfefe/ef08e583e276e7617cd316ba2382fc40 function getMarkdownRegex(numWrapperChars: number) { - const asteriskWrapper = `(?:\\*){${numWrapperChars}}` - const underscoreWrapper = `(?:_){${numWrapperChars}}` - return new RegExp(`^${asteriskWrapper}(.+?)${asteriskWrapper}$|^${underscoreWrapper}(.+?)${underscoreWrapper}$`) + const asteriskWrapper = `(?:\\*){${numWrapperChars}}`; + const underscoreWrapper = `(?:_){${numWrapperChars}}`; + return new RegExp( + `^${asteriskWrapper}(.+?)${asteriskWrapper}$|^${underscoreWrapper}(.+?)${underscoreWrapper}$` + ); } const MARKDOWN_REGEX = { BOLD_AND_ITALIC: getMarkdownRegex(3), BOLD: getMarkdownRegex(2), ITALIC: getMarkdownRegex(1), -} +}; const utils = { nonQueueTask: async (name: string, data: Record) => { @@ -106,41 +108,51 @@ const utils = { return json; }, - validatorErrToStr: (errorList: Failure[]) => - '\n' + - errorList.map((error) => ` => ${error.path.join('.')}: ${error.message}`).join('\n') + + validatorErrToStr: (errorList: Failure[]) => + '\n' + + errorList.map((error) => ` => ${error.path.join('.')}: ${error.message}`).join('\n') + '\n', /** * The Cypress GUI runner allows markdown in `cy.log` messages. We can take this * into account for our loggers as well. */ - applyMessageMarkdown(message: string, {bold, italic, processContents}: { - bold: (str: string) => string, - italic: (str: string) => string, - processContents?: (str: string) => string - }) { - let contentsHaveBeenProcessed = false - const maybeProcessContents = (str: string) => { - if (contentsHaveBeenProcessed || !processContents) return str - contentsHaveBeenProcessed = true - return processContents(str) + applyMessageMarkdown( + message: string, + { + bold, + italic, + processContents, + }: { + bold: (str: string) => string; + italic: (str: string) => string; + processContents?: (str: string) => string; } + ) { + let contentsHaveBeenProcessed = false; + const maybeProcessContents = (str: string) => { + if (contentsHaveBeenProcessed || !processContents) return str; + contentsHaveBeenProcessed = true; + return processContents(str); + }; // bold and italic, i.e. ***text*** or ___text___ - message = message.replace(MARKDOWN_REGEX.BOLD_AND_ITALIC, - (str, group1, group2) => bold(italic(maybeProcessContents(group1 || group2)))) + message = message.replace(MARKDOWN_REGEX.BOLD_AND_ITALIC, (str, group1, group2) => + bold(italic(maybeProcessContents(group1 || group2))) + ); // bold, i.e. **text** or __text__ - message = message.replace(MARKDOWN_REGEX.BOLD, - (str, group1, group2) => bold(maybeProcessContents(group1 || group2))) + message = message.replace(MARKDOWN_REGEX.BOLD, (str, group1, group2) => + bold(maybeProcessContents(group1 || group2)) + ); // italic, i.e. *text* or _text_ - message = message.replace(MARKDOWN_REGEX.ITALIC, - (str, group1, group2) => italic(maybeProcessContents(group1 || group2))) + message = message.replace(MARKDOWN_REGEX.ITALIC, (str, group1, group2) => + italic(maybeProcessContents(group1 || group2)) + ); - return maybeProcessContents(message) - } -} + return maybeProcessContents(message); + }, +}; export default utils; diff --git a/test/specs/utils.spec.js b/test/specs/utils.spec.js index ed50fa6..c192ca1 100644 --- a/test/specs/utils.spec.js +++ b/test/specs/utils.spec.js @@ -1,33 +1,36 @@ -import utils from '../../src/utils' -import {expect} from 'chai' - -const {applyMessageMarkdown} = utils - -describe('utils', () => { - describe('applyMessageMarkdown', () => { - it('correctly detects markdown and returns processed message with functions applied', () => { - const LONG_MSG = "abc123".repeat(5) - const tests = [ - ['*text text*', 'text text'], - ['_text text_', 'text text'], - ['**text text**', 'text text'], - ['__text text__', 'text text'], - ['***text text***', 'text text'], - ['___text text___', 'text text'], - ['_text text_text_', 'text text_text'], - ['text text_','text text_'], - ['*text text','*text text'], - ['*text text**', 'text text*'], - ['**text text*', '*text text'], - [`**${LONG_MSG}**`, `${LONG_MSG.substring(0, 20)}...`], - ] - tests.forEach(([message, expected]) => { - expect(applyMessageMarkdown(message, { - bold: (str) => `${str}`, - italic: (str) => `${str}`, - processContents: (c) => c.length > 20 ? (c.substring(0, 20) + '...') : c - }), message).to.deep.equal(expected) - }) - }) - }) -}) \ No newline at end of file +import utils from '../../src/utils'; +import {expect} from 'chai'; + +const {applyMessageMarkdown} = utils; + +describe('utils', () => { + describe('applyMessageMarkdown', () => { + it('correctly detects markdown and returns processed message with functions applied', () => { + const LONG_MSG = 'abc123'.repeat(5); + const tests = [ + ['*text text*', 'text text'], + ['_text text_', 'text text'], + ['**text text**', 'text text'], + ['__text text__', 'text text'], + ['***text text***', 'text text'], + ['___text text___', 'text text'], + ['_text text_text_', 'text text_text'], + ['text text_', 'text text_'], + ['*text text', '*text text'], + ['*text text**', 'text text*'], + ['**text text*', '*text text'], + [`**${LONG_MSG}**`, `${LONG_MSG.substring(0, 20)}...`], + ]; + tests.forEach(([message, expected]) => { + expect( + applyMessageMarkdown(message, { + bold: (str) => `${str}`, + italic: (str) => `${str}`, + processContents: (c) => (c.length > 20 ? c.substring(0, 20) + '...' : c), + }), + message + ).to.deep.equal(expected); + }); + }); + }); +}); From f0867a71a95f59cf650fc7173e6e3946d9a82e04 Mon Sep 17 00:00:00 2001 From: Blake Vandercar Date: Mon, 18 Nov 2024 14:16:38 -0700 Subject: [PATCH 18/22] add integration test --- test/cypress/integration/logMarkdown.spec.js | 21 ++++++++++++ test/specs/commandsLogging.spec.js | 34 +++++++++++++++++++- 2 files changed, 54 insertions(+), 1 deletion(-) create mode 100644 test/cypress/integration/logMarkdown.spec.js diff --git a/test/cypress/integration/logMarkdown.spec.js b/test/cypress/integration/logMarkdown.spec.js new file mode 100644 index 0000000..189ebb2 --- /dev/null +++ b/test/cypress/integration/logMarkdown.spec.js @@ -0,0 +1,21 @@ +describe('cy.log markdown.', () => { + /** + * Covers: cy.log markdown to console + */ + it('cy.log markdown.', () => { + cy.log('_This is an_italic* log._'); + cy.log('*This is an_italic* log.*'); + cy.log('**This is a__bold* log.**'); + cy.log('__This is a__bold* log.__'); + cy.log('***This is a_bold and italic* log.***'); + cy.log('___This is a_bold and italic* log.___'); + cy.log('_This is a normal log'); + cy.log('This is a normal log_'); + cy.log('__This is a normal log'); + cy.log('This is a normal log__'); + cy.log('*This is a normal log'); + cy.log('This is a normal log*'); + cy.log('**This is a normal log'); + cy.log('This is a normal log**'); + }); +}); diff --git a/test/specs/commandsLogging.spec.js b/test/specs/commandsLogging.spec.js index a7c9753..2a8011b 100755 --- a/test/specs/commandsLogging.spec.js +++ b/test/specs/commandsLogging.spec.js @@ -1,5 +1,6 @@ -import {PADDING, ICONS, clean, runTest, commandBase, logLastRun} from '../utils'; +import {PADDING, ICONS, clean, runTest, commandBase, logLastRun, runTestContinuous} from '../utils'; import {expect} from 'chai'; +import chalk from 'chalk'; describe('Commands logging.', () => { afterEach(function () { @@ -238,4 +239,35 @@ describe('Commands logging.', () => { ); }); }).timeout(60000); + + it('Should apply chalk markdown to console', async () => { + await runTestContinuous( + commandBase( + ['enableContinuousLogging=1', 'printLogsToConsoleAlways=1'], + ['logMarkdown.spec.js'] + ), + (error, stdout, stderr) => { + const lines = stdout.split('\n'); + [ + chalk.italic('This is an_italic* log.'), + chalk.italic('This is an_italic* log.'), + chalk.bold('This is a__bold* log.'), + chalk.bold('This is a__bold* log.'), + chalk.bold(chalk.italic('This is a_bold and italic* log.')), + chalk.bold(chalk.italic('This is a_bold and italic* log.')), + '_This is a normal log', + 'This is a normal log_', + '__This is a normal log', + 'This is a normal log__', + '*This is a normal log', + 'This is a normal log*', + '**This is a normal log', + 'This is a normal log**', + ].forEach((msg, index) => { + console.log(lines[index + 4]); + expect(lines[index + 4]).to.equal(` cy:log ${ICONS.info} ${msg}`); + }); + } + ); + }).timeout(60000); }); From b8f452efcd5fde04ae64659d712ac5b52323af6f Mon Sep 17 00:00:00 2001 From: Blake Vandercar Date: Mon, 18 Nov 2024 14:16:58 -0700 Subject: [PATCH 19/22] revert --- test/specs/commandsLogging.spec.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/specs/commandsLogging.spec.js b/test/specs/commandsLogging.spec.js index 2a8011b..d669875 100755 --- a/test/specs/commandsLogging.spec.js +++ b/test/specs/commandsLogging.spec.js @@ -241,9 +241,9 @@ describe('Commands logging.', () => { }).timeout(60000); it('Should apply chalk markdown to console', async () => { - await runTestContinuous( + await runTest( commandBase( - ['enableContinuousLogging=1', 'printLogsToConsoleAlways=1'], + ['printLogsToConsoleAlways=1'], ['logMarkdown.spec.js'] ), (error, stdout, stderr) => { From 87ab4ba7fb128f08f4d8539d37e66b9dec7ffed3 Mon Sep 17 00:00:00 2001 From: Blake Vandercar Date: Mon, 18 Nov 2024 14:38:25 -0700 Subject: [PATCH 20/22] yarn format --- test/specs/commandsLogging.spec.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/test/specs/commandsLogging.spec.js b/test/specs/commandsLogging.spec.js index d669875..367fc12 100755 --- a/test/specs/commandsLogging.spec.js +++ b/test/specs/commandsLogging.spec.js @@ -242,10 +242,7 @@ describe('Commands logging.', () => { it('Should apply chalk markdown to console', async () => { await runTest( - commandBase( - ['printLogsToConsoleAlways=1'], - ['logMarkdown.spec.js'] - ), + commandBase(['printLogsToConsoleAlways=1'], ['logMarkdown.spec.js']), (error, stdout, stderr) => { const lines = stdout.split('\n'); [ From 09bb5ac9ace615578cc9f7a822fa633a213f3091 Mon Sep 17 00:00:00 2001 From: Blake Vandercar Date: Mon, 18 Nov 2024 14:39:41 -0700 Subject: [PATCH 21/22] attempt test fix --- test/specs/commandsLogging.spec.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/test/specs/commandsLogging.spec.js b/test/specs/commandsLogging.spec.js index 367fc12..69fb558 100755 --- a/test/specs/commandsLogging.spec.js +++ b/test/specs/commandsLogging.spec.js @@ -241,8 +241,12 @@ describe('Commands logging.', () => { }).timeout(60000); it('Should apply chalk markdown to console', async () => { - await runTest( - commandBase(['printLogsToConsoleAlways=1'], ['logMarkdown.spec.js']), + // runTestContinuous to use spawn instead of exec, in order to get unicode stdout + await runTestContinuous( + commandBase( + ['printLogsToConsoleAlways=1', 'enableContinuousLogging=1'], + ['logMarkdown.spec.js'] + ), (error, stdout, stderr) => { const lines = stdout.split('\n'); [ From 07c1b689f5bb505ee1a2b8b84e2eee5a06652400 Mon Sep 17 00:00:00 2001 From: Blake Vandercar Date: Mon, 18 Nov 2024 14:49:03 -0700 Subject: [PATCH 22/22] remove log --- test/specs/commandsLogging.spec.js | 1 - 1 file changed, 1 deletion(-) diff --git a/test/specs/commandsLogging.spec.js b/test/specs/commandsLogging.spec.js index 69fb558..4d19285 100755 --- a/test/specs/commandsLogging.spec.js +++ b/test/specs/commandsLogging.spec.js @@ -265,7 +265,6 @@ describe('Commands logging.', () => { '**This is a normal log', 'This is a normal log**', ].forEach((msg, index) => { - console.log(lines[index + 4]); expect(lines[index + 4]).to.equal(` cy:log ${ICONS.info} ${msg}`); }); }