Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(bug) toMatchSnapshot() can't handle newline characters "\n" #181

Open
tschortsch opened this issue May 19, 2021 · 0 comments
Open

(bug) toMatchSnapshot() can't handle newline characters "\n" #181

tschortsch opened this issue May 19, 2021 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@tschortsch
Copy link

Describe the bug
When I call .toMatchSnapshot() on a string which contains newline characters "\n" the snapshot gets saved with newlines inside:

<h1>My Heading</h1>
<div>My Div</div>

When I re-run the test it complains that the snapshot doesn't match the actual content:

"<h1>My Heading</h1>\n<div>My Div</div>"

Diff:

-
-<h1>My Heading</h1>
-<div>My Div</div>
+"<h1>My Heading</h1>\n<div>My Div</div>"

To Reproduce
Steps to reproduce the behavior:

  1. Create the following test case:
    context('test with newline', () => {
      it('should match snapshot', () => {
        cy.wrap('<h1>My Heading</h1>\n<div>My Div</div>').toMatchSnapshot();
      });
    });
    
  2. Run the test to create snapshot
  3. Re-run the test
  4. Snapshot doesn't match

Expected behavior
The snapshots should match.

Desktop (please complete the following information):

  • OS: macOS X Big Sur
  • Cypress Version: 7.3.0
  • Plugin version: 1.4.4
@tschortsch tschortsch added the bug Something isn't working label May 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants