From 297abbbd52fd93b326074f914c7ae751f3ee7cb7 Mon Sep 17 00:00:00 2001 From: Jennifer Shehane Date: Mon, 20 May 2024 13:41:37 -0400 Subject: [PATCH] fix: Add optional regex check for comma preceding 'but' in assertions for command formatting (#29517) * fix: Add optional regex check for comma preceding 'but' in assertions for command formatting * empty commit * changelog entry --- cli/CHANGELOG.md | 3 ++- packages/reporter/cypress/e2e/unit/formatted_message.cy.ts | 7 +++++++ packages/reporter/src/commands/command.tsx | 3 ++- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/cli/CHANGELOG.md b/cli/CHANGELOG.md index 25c1c5f1fd93..7e4a0fe01f45 100644 --- a/cli/CHANGELOG.md +++ b/cli/CHANGELOG.md @@ -6,8 +6,9 @@ _Released 5/21/2024 (PENDING)_ **Bugfixes:** - Fixed an issue where orphaned Electron processes were inadvertently terminating the browser's CRI client. Fixes [#28397](https://github.com/cypress-io/cypress/issues/28397). Fixed in [#29515](https://github.com/cypress-io/cypress/pull/29515). -- Fixed an issue where Cypress was unable to search in the Specs list for files or folders containing numbers. Fixes [#29034](https://github.com/cypress-io/cypress/issues/29034). - Fixed an issue where Cypress would use the wrong URL to upload Test Replay recordings when it wasn't able to determine the upload URL. It now displays an error when the upload URL cannot be determined, rather than a "Request Entity Too Large" error. Addressed in [#29512](https://github.com/cypress-io/cypress/pull/29512). +- Fixed an issue where Cypress was unable to search in the Specs list for files or folders containing numbers. Fixes [#29034](https://github.com/cypress-io/cypress/issues/29034). +- Fixed the display of some command assertions. Fixed in [#29517](https://github.com/cypress-io/cypress/pull/29517). **Dependency Updates:** diff --git a/packages/reporter/cypress/e2e/unit/formatted_message.cy.ts b/packages/reporter/cypress/e2e/unit/formatted_message.cy.ts index 4d8b951c6d15..45c792819b09 100644 --- a/packages/reporter/cypress/e2e/unit/formatted_message.cy.ts +++ b/packages/reporter/cypress/e2e/unit/formatted_message.cy.ts @@ -71,6 +71,13 @@ describe('formattedMessage', () => { expect(result).to.equal('expected span to have CSS property background-color with the value rgb(0, 0, 0), but the value was rgba(0, 0, 0, 0)') }) + it('bolds asterisks with "but" without comma', () => { + const specialMessage = 'expected **foo** to have length above **1** but got **0**' + const result = formattedMessage(specialMessage) + + expect(result).to.equal('expected foo to have length above 1 but got 0') + }) + it('bolds asterisks with simple assertions', () => { const specialMessage = 'expected **dom** to be visible' const result = formattedMessage(specialMessage, 'assert') diff --git a/packages/reporter/src/commands/command.tsx b/packages/reporter/src/commands/command.tsx index 76ee5b1d9c9a..62a9dc6228d0 100644 --- a/packages/reporter/src/commands/command.tsx +++ b/packages/reporter/src/commands/command.tsx @@ -35,8 +35,9 @@ const asterisksRegex = /^\*\*(.+?)\*\*$/gs // 'expected **** to exist in the DOM' // `expected **glob*glob** to contain *****` // `expected **** to have CSS property **background-color** with the value **rgb(0, 0, 0)**, but the value was **rgba(0, 0, 0, 0)**` +// `expected **foo** to have length above **1** but got **0**` // `Custom message expected **** to exist in the DOM` -const assertionRegex = /^.*?expected | to[^\*]+| not[^\*]+| with[^\*]+|, but[^\*]+/g +const assertionRegex = /^.*?expected | to[^\*]+| not[^\*]+| with[^\*]+|,? but[^\*]+/g // used to format the display of command messages and error messages // we use markdown syntax within our error messages (code ticks, urls, etc)