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

Snapshot diff view doesn't render whitespace #2287

Closed
SimenB opened this issue Dec 11, 2016 · 3 comments · Fixed by #2347
Closed

Snapshot diff view doesn't render whitespace #2287

SimenB opened this issue Dec 11, 2016 · 3 comments · Fixed by #2347

Comments

@SimenB
Copy link
Member

SimenB commented Dec 11, 2016

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

What is the current behavior?
Adding or removing trailing spaces in a component gives a failing snapshot without showing the diff.

image

If I mark the diff in the terminal I can se it, so it's there, it's just not highlighted by Jest.

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal repository on GitHub that we can npm install and npm test.

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

test('renders correctly', () => {
  const tree = renderer.create(
    <div>
      <span>Hello </span>
    </div>,
  ).toJSON();

  expect(tree).toMatchSnapshot();
});

Remove or add a trailing whitespace in the span, and get a failing test, but the diff view doesn't indicate why it failed.

What is the expected behavior?
Adding or removing trailing space is shown like this in my git diff:
image
Something similar would be great

Run Jest again with --debug and provide the full configuration it prints. Please mention your node and npm version and operating system.

node@6.9.1, yarn@0.18.0, macOS Sierra

jest version = 17.0.3
test framework = jasmine2
config = {
  "moduleFileExtensions": [
    "jsx",
    "js",
    "json"
  ],
  "moduleNameMapper": [
    [
      "^.+\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$",
      "/Users/simen/Development/innfinn-es/config/jest/FileStub.js"
    ],
    [
      "^.+\\.css$",
      "/Users/simen/Development/innfinn-es/config/jest/CSSStub.js"
    ]
  ],
  "setupFiles": [
    "/Users/simen/Development/innfinn-es/config/polyfills.js"
  ],
  "testPathIgnorePatterns": [
    "/Users/simen/Development/innfinn-es/(build|docs|node_modules)/"
  ],
  "testEnvironment": "/Users/simen/Development/innfinn-es/node_modules/jest-environment-jsdom/build/index.js",
  "rootDir": "/Users/simen/Development/innfinn-es",
  "name": "-Users-simen-Development-innfinn-es",
  "testRunner": "/Users/simen/Development/innfinn-es/node_modules/jest-jasmine2/build/index.js",
  "transform": [
    [
      "^.+\\.jsx?$",
      "/Users/simen/Development/innfinn-es/node_modules/babel-jest/build/index.js"
    ]
  ],
  "usesBabelJest": true,
  "automock": false,
  "bail": false,
  "browser": false,
  "cacheDirectory": "/var/folders/58/x7ryp52n7mxbtkld6lr0bqg00000gn/T/jest",
  "coveragePathIgnorePatterns": [
    "/node_modules/"
  ],
  "coverageReporters": [
    "json",
    "text",
    "lcov",
    "clover"
  ],
  "expand": false,
  "globals": {},
  "haste": {
    "providesModuleNodeModules": []
  },
  "mocksPattern": "__mocks__",
  "moduleDirectories": [
    "node_modules"
  ],
  "modulePathIgnorePatterns": [],
  "noStackTrace": false,
  "notify": false,
  "preset": null,
  "resetMocks": false,
  "resetModules": false,
  "snapshotSerializers": [],
  "testPathDirs": [
    "/Users/simen/Development/innfinn-es"
  ],
  "testRegex": "(/__tests__/.*|\\.(test|spec))\\.jsx?$",
  "testURL": "about:blank",
  "timers": "real",
  "transformIgnorePatterns": [
    "/node_modules/"
  ],
  "useStderr": false,
  "verbose": null,
  "watch": true,
  "cache": true,
  "watchman": true
}
@thymikee
Copy link
Collaborator

Filed a PR for that. This is the simplest implementation I could think of. Does this satisfy your need?

@cpojer
Copy link
Member

cpojer commented Dec 16, 2016

Closing this in favor of the PR.

@cpojer cpojer closed this as completed Dec 16, 2016
@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 14, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants