-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: format special characters correctly (#22537)
* Update packages/reporter/cypress/e2e/unit/formatted_message.cy.ts Co-authored-by: Rachel <rachel@cypress.io> * Update packages/reporter/cypress/e2e/unit/formatted_message.cy.ts Co-authored-by: Rachel <rachel@cypress.io> * Remove extra spaces Co-authored-by: gitstart <gitstart@users.noreply.github.com> Co-authored-by: Matt Henkes <mjhenkes@gmail.com> Co-authored-by: Rachel <rachel@cypress.io> Co-authored-by: Tyler Biethman <tbiethman@users.noreply.github.com> Co-authored-by: Benjamin Mayanja <vibenjamin6@gmail.com>
- Loading branch information
1 parent
1c44eae
commit 90fe502
Showing
3 changed files
with
46 additions
and
5 deletions.
There are no files selected for viewing
30 changes: 30 additions & 0 deletions
30
packages/reporter/cypress/e2e/unit/formatted_message.cy.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { formattedMessage } from '../../../src/commands/command' | ||
|
||
describe('formattedMessage', () => { | ||
it('returns empty string when message is falsy', () => { | ||
const result = formattedMessage('') | ||
|
||
expect(result).to.equal('') | ||
}) | ||
|
||
it('maintains special characters when using "to match"', () => { | ||
const specialMessage = 'expected **__*abcdef*__** to match /__.*abcdef.*__/' | ||
const result = formattedMessage(specialMessage) | ||
|
||
expect(result).to.equal('expected <strong><strong><em>abcdef</em></strong></strong> to match <strong>/__.*abcdef.*__/</strong>') | ||
}) | ||
|
||
it('maintains special characters when using "to contain"', () => { | ||
const specialMessage = 'expected ***abcdef*** to equal ***abcdef***' | ||
const result = formattedMessage(specialMessage) | ||
|
||
expect(result).to.equal('expected <em><strong>abcdef</strong></em> to equal <strong>***abcdef***</strong>') | ||
}) | ||
|
||
it('does NOT maintain special characters when "to equal" or "to match" are not in assertion', () => { | ||
const specialMessage = 'expected ***abcdef*** to contain ***abcdef***' | ||
const result = formattedMessage(specialMessage) | ||
|
||
expect(result).to.equal('expected <em><strong>abcdef</strong></em> to contain <em><strong>abcdef</strong></em>') | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
90fe502
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Circle has built the
linux x64
version of the Test Runner.Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.
Run this command to install the pre-release locally:
90fe502
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Circle has built the
linux arm64
version of the Test Runner.Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.
Run this command to install the pre-release locally:
90fe502
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Circle has built the
darwin arm64
version of the Test Runner.Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.
Run this command to install the pre-release locally:
90fe502
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Circle has built the
darwin x64
version of the Test Runner.Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.
Run this command to install the pre-release locally: