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

snapshotDiff between two single line strings output null #22

Closed
allotrop3 opened this issue Jan 11, 2018 · 2 comments
Closed

snapshotDiff between two single line strings output null #22

allotrop3 opened this issue Jan 11, 2018 · 2 comments
Labels

Comments

@allotrop3
Copy link

allotrop3 commented Jan 11, 2018

Code:

expect(snapshotDiff("foo", "bar")).toMatchSnapshot();

Result:

Received value
    Snapshot Diff:
    null

It seems adding a new line to the end of both arguments results in a valid snapshot diff.

Code

expect(snapshotDiff("foo" + "\n", "bar" + "\n")).toMatchSnapshot();

Result

Received value
    Snapshot Diff:
    - First value
    + Second value

    - foo
    + bar
@thymikee
Copy link
Member

Hm, maybe we should add the newline implicitly if there's none? I'm not sure why it doesn't work in general though, anyone mind investigating?

@thymikee thymikee added the bug label Jan 11, 2018
@pedrottimark
Copy link

pedrottimark commented Jan 11, 2018

Let’s see if it works correctly after #21 because of jestjs/jest#4520

EDIT: It looks like it is necessary to add newline if both strings are single line, see:
https://github.com/facebook/jest/blob/master/packages/jest-diff/src/index.js#L89-L95

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants