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

Having a \r in the snapshot output always fails #2969

Closed
Swatinem opened this issue Feb 22, 2017 · 1 comment · Fixed by #3002
Closed

Having a \r in the snapshot output always fails #2969

Swatinem opened this issue Feb 22, 2017 · 1 comment · Fixed by #3002

Comments

@Swatinem
Copy link

Do you want to request a feature or report a bug?

bug

What is the current behavior?

When using snapshot testing with the react-test-renderer, rendering some innerHTML containing \r leads to unstable snapshots

If the current behavior is a bug, please provide the steps to reproduce and either a repl.it demo through https://repl.it/languages/jest or a minimal repository on GitHub that we can yarn install and yarn test.

Running the following test will always fail once you have created a snapshot

import React from "react";
import renderer from "react-test-renderer";

const renderToString = element => renderer.create(element);

it("should handle \\r in a stable manner", () => {
	const el = (<div
		dangerouslySetInnerHTML={{__html: "a\r\nb\r\nc"}} />);
	expect(renderToString(el)).toMatchSnapshot();
});
 FAIL  lib/__tests__/cr.test.js
  ● should handle \r in a stable manner

    Error
      Error: expect(value).toMatchSnapshot()
      
      Received value does not match stored snapshot 1.
      
      - Snapshot
      + Received
      
       <div
         dangerouslySetInnerHTML={
           Object {
      -      "__html": "a
      -    b
      +      "__html": "a
      +    b
           c",
           }
         }
       />
      at Object.<anonymous> (lib/__tests__/cr.test.js:9:29)

What is the expected behavior?

Test should succeed :-)

Please provide your exact Jest configuration and mention your Jest, node, yarn/npm version and operating system.

Jest 19, on Archlinux

@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 13, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant