-
-
Notifications
You must be signed in to change notification settings - Fork 6.6k
Closed
Description
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
Metadata
Metadata
Assignees
Labels
No labels