From c2e7b60f541e01bb1e7f54f8582c458f619f9690 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nil=20G=C3=A0llego?= <73447234+nilgaar@users.noreply.github.com> Date: Tue, 24 Jan 2023 03:58:06 +0100 Subject: [PATCH] feat: Display line break in cy.log (#25467) * add breaklines for log messages * update cy.log tests * run ci Co-authored-by: Bill Glesias --- packages/driver/cypress/e2e/cypress/log.cy.js | 7 +++++++ packages/reporter/cypress/e2e/unit/formatted_message.cy.ts | 2 +- packages/reporter/src/commands/command.tsx | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/packages/driver/cypress/e2e/cypress/log.cy.js b/packages/driver/cypress/e2e/cypress/log.cy.js index c534282bd670..f548b7c9eb1a 100644 --- a/packages/driver/cypress/e2e/cypress/log.cy.js +++ b/packages/driver/cypress/e2e/cypress/log.cy.js @@ -53,6 +53,13 @@ describe('src/cypress/log', function () { expect(this.cy.createSnapshot).not.to.be.called expect(result).to.equal(log) }) + + it('line break persists in snapshot', function () { + const log = this.log({ 'message': 'First line \n Second Line' }) + const result = log.snapshot() + + expect(result).to.equal(log) + }) }) context('countLogsByTests', () => { diff --git a/packages/reporter/cypress/e2e/unit/formatted_message.cy.ts b/packages/reporter/cypress/e2e/unit/formatted_message.cy.ts index 1e541c574e1a..833b1f45fe13 100644 --- a/packages/reporter/cypress/e2e/unit/formatted_message.cy.ts +++ b/packages/reporter/cypress/e2e/unit/formatted_message.cy.ts @@ -32,6 +32,6 @@ describe('formattedMessage', () => { const specialMessage = 'hello\n world `code block`' const result = formattedMessage(specialMessage) - expect(result).to.equal('hello\n world code block') + expect(result).to.equal('hello
\n world code block') }) }) diff --git a/packages/reporter/src/commands/command.tsx b/packages/reporter/src/commands/command.tsx index 0578c4c7d149..d73d35410bb2 100644 --- a/packages/reporter/src/commands/command.tsx +++ b/packages/reporter/src/commands/command.tsx @@ -24,7 +24,7 @@ import HiddenIcon from '-!react-svg-loader!@packages/frontend-shared/src/assets/ import PinIcon from '-!react-svg-loader!@packages/frontend-shared/src/assets/icons/object-pin_x16.svg' import RunningIcon from '-!react-svg-loader!@packages/frontend-shared/src/assets/icons/status-running_x16.svg' -const md = new Markdown() +const md = new Markdown({ breaks: true }) const displayName = (model: CommandModel) => model.displayName || model.name const nameClassName = (name: string) => name.replace(/(\s+)/g, '-')