{"action":"created","issue":{"url":"https://api.github.com/repos/facebook/jest/issues/2307","repository_url":"https://api.github.com/repos/facebook/jest","labels_url":"https://api.github.com/repos/facebook/jest/issues/2307/labels{/name}","comments_url":"https://api.github.com/repos/facebook/jest/issues/2307/comments","events_url":"https://api.github.com/repos/facebook/jest/issues/2307/events","html_url":"https://github.com/facebook/jest/issues/2307","id":195164586,"number":2307,"title":"No visual difference failing snapshot tests","user":{"login":"JakeDawkins","id":9259509,"avatar_url":"https://avatars.githubusercontent.com/u/9259509?v=3","gravatar_id":"","url":"https://api.github.com/users/JakeDawkins","html_url":"https://github.com/JakeDawkins","followers_url":"https://api.github.com/users/JakeDawkins/followers","following_url":"https://api.github.com/users/JakeDawkins/following{/other_user}","gists_url":"https://api.github.com/users/JakeDawkins/gists{/gist_id}","starred_url":"https://api.github.com/users/JakeDawkins/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JakeDawkins/subscriptions","organizations_url":"https://api.github.com/users/JakeDawkins/orgs","repos_url":"https://api.github.com/users/JakeDawkins/repos","events_url":"https://api.github.com/users/JakeDawkins/events{/privacy}","received_events_url":"https://api.github.com/users/JakeDawkins/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2016-12-13T05:24:15Z","updated_at":"2016-12-13T13:18:31Z","closed_at":null,"body":"I believe I have a misconception with how snapshots are being processed. That or there is a bug with snapshot testing.\r\n\r\nI am trying to write a custom serializer using jest's default serializer in `jest/packages/jest-snapshot/src/utils.js`. \r\n\r\nThe reason I'm trying to do this is that I like the verbosity of `enzyme-to-json` and prefer using it to [jest-serializer-enzyme](https://github.com/rogeliog/jest-serializer-enzyme) that uses enzyme's `debug` method, but I would like to not have to import it and wrap my enzyme components with its methods when snapshot testing.\r\n\r\nAfter importing the stock Jest serializer and passing the output of `enzyme-to-json` through it and returning, I'm getting a snapshot failure with the message \r\n```\r\n    expect(value).toMatchSnapshot()\r\n\r\n    Received value does not match stored snapshot 1.\r\n\r\n    Compared values have no visual difference.\r\n```\r\n\r\nMy question is are there any other things that the snapshot tests look for when testing the equality, or should this method work theoretically? Here is the example of what I'm trying to do.\r\n\r\n```\r\nvar { shallowToJson, mountToJson } = require(\"enzyme-to-json\");\r\nvar ShallowWrapper = require('enzyme/ShallowWrapper');\r\nvar ReactWrapper = require(\"enzyme/ReactWrapper\");\r\nvar { serialize } = require(\"jest-snapshot/build/utils\");\r\n\r\n...\r\n\r\nmodule.exports = {\r\n  test(val) {\r\n    ...\r\n  },\r\n  print(val) {\r\n    // pick which enzyme-to-json method to use to parse input\r\n    const parser = whichParser(val);\r\n    const parsed = parser(val);\r\n\r\n    if (parsed === \"\") {\r\n      return \"null\";\r\n    }\r\n\r\n    return serialize(parsed);\r\n  },\r\n};\r\n\r\n```\r\n\r\nThe actual test is run like so:\r\n```\r\n    const component = mount(<SmallButton />);\r\n    expect(component).toMatchSnapshot();\r\n```\r\n\r\nAlso, my config is:\r\n```\r\njest version = 17.0.3\r\ntest framework = jasmine2\r\nconfig = {\r\n  \"transform\": [\r\n    [\r\n      \".*\",\r\n      \"/Users/jake.dawkins/Sites/Apollos/Holtzmann/.scripts/jestPreprocessor.js\"\r\n    ]\r\n  ],\r\n  \"coverageDirectory\": \"/Users/jake.dawkins/Sites/Apollos/Holtzmann/.coverage\",\r\n  \"collectCoverageFrom\": [\r\n    \"client/**/*.{js,jsx}\",\r\n    \"server/**/*.{js,jsx}\",\r\n    \"imports/**/*.{js,jsx}\"\r\n  ],\r\n  \"coveragePathIgnorePatterns\": [\r\n    \"__stories__/\",\r\n    \"/Users/jake.dawkins/Sites/Apollos/Holtzmann/imports/methods/\",\r\n    \"/Users/jake.dawkins/Sites/Apollos/Holtzmann/server/deprecated/\",\r\n    \"/Users/jake.dawkins/Sites/Apollos/Holtzmann/imports/database/\",\r\n    \"/Users/jake.dawkins/Sites/Apollos/Holtzmann/imports/util/xml.js\"\r\n  ],\r\n  \"testPathIgnorePatterns\": [\r\n    \"/node_modules/\",\r\n    \"/.meteor/\"\r\n  ],\r\n  \"moduleNameMapper\": [\r\n    [\r\n      \"^meteor/(.*)\",\r\n      \"/Users/jake.dawkins/Sites/Apollos/Holtzmann/.meteor/mocks/$1.js\"\r\n    ]\r\n  ],\r\n  \"setupFiles\": [\r\n    \"/Users/jake.dawkins/Sites/Apollos/Holtzmann/.scripts/before_test.js\"\r\n  ],\r\n  \"snapshotSerializers\": [\r\n    \"/Users/jake.dawkins/Sites/Apollos/Holtzmann/imports/util/serializer\"\r\n  ],\r\n  \"rootDir\": \"/Users/jake.dawkins/Sites/Apollos/Holtzmann\",\r\n  \"name\": \"-Users-jake.dawkins-Sites-Apollos-Holtzmann\",\r\n  \"testRunner\": \"/Users/jake.dawkins/Sites/Apollos/Holtzmann/node_modules/jest-jasmine2/build/index.js\",\r\n  \"automock\": false,\r\n  \"bail\": false,\r\n  \"browser\": false,\r\n  \"cacheDirectory\": \"/var/folders/s2/s4pvh0l563x3lxf9zc9xt4994b4kvf/T/jest\",\r\n  \"coverageReporters\": [\r\n    \"json\",\r\n    \"text\",\r\n    \"lcov\",\r\n    \"clover\"\r\n  ],\r\n  \"expand\": false,\r\n  \"globals\": {},\r\n  \"haste\": {\r\n    \"providesModuleNodeModules\": []\r\n  },\r\n  \"mocksPattern\": \"__mocks__\",\r\n  \"moduleDirectories\": [\r\n    \"node_modules\"\r\n  ],\r\n  \"moduleFileExtensions\": [\r\n    \"js\",\r\n    \"json\",\r\n    \"jsx\",\r\n    \"node\"\r\n  ],\r\n  \"modulePathIgnorePatterns\": [],\r\n  \"noStackTrace\": false,\r\n  \"notify\": false,\r\n  \"preset\": null,\r\n  \"resetMocks\": false,\r\n  \"resetModules\": false,\r\n  \"testEnvironment\": \"jest-environment-jsdom\",\r\n  \"testPathDirs\": [\r\n    \"/Users/jake.dawkins/Sites/Apollos/Holtzmann\"\r\n  ],\r\n  \"testRegex\": \"(/__tests__/.*|\\\\.(test|spec))\\\\.jsx?$\",\r\n  \"testURL\": \"about:blank\",\r\n  \"timers\": \"real\",\r\n  \"transformIgnorePatterns\": [\r\n    \"/node_modules/\"\r\n  ],\r\n  \"useStderr\": false,\r\n  \"verbose\": null,\r\n  \"watch\": false,\r\n  \"cache\": true,\r\n  \"watchman\": true\r\n}\r\n```\r\n\r\nThanks in advance! I love using Jest 💯 \r\n"},"comment":{"url":"https://api.github.com/repos/facebook/jest/issues/comments/266736018","html_url":"https://github.com/facebook/jest/issues/2307#issuecomment-266736018","issue_url":"https://api.github.com/repos/facebook/jest/issues/2307","id":266736018,"user":{"login":"JakeDawkins","id":9259509,"avatar_url":"https://avatars.githubusercontent.com/u/9259509?v=3","gravatar_id":"","url":"https://api.github.com/users/JakeDawkins","html_url":"https://github.com/JakeDawkins","followers_url":"https://api.github.com/users/JakeDawkins/followers","following_url":"https://api.github.com/users/JakeDawkins/following{/other_user}","gists_url":"https://api.github.com/users/JakeDawkins/gists{/gist_id}","starred_url":"https://api.github.com/users/JakeDawkins/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JakeDawkins/subscriptions","organizations_url":"https://api.github.com/users/JakeDawkins/orgs","repos_url":"https://api.github.com/users/JakeDawkins/repos","events_url":"https://api.github.com/users/JakeDawkins/events{/privacy}","received_events_url":"https://api.github.com/users/JakeDawkins/received_events","type":"User","site_admin":false},"created_at":"2016-12-13T13:18:31Z","updated_at":"2016-12-13T13:18:31Z","body":"@thymikee \r\n\r\nI just realized that Enzyme-to-json has a serializer in its most recent version, so I won't be continuing to work on this test. I'll leave the issue open in case this is a bug. It can be closed, otherwise. \r\n\r\n[Here's a link](https://github.com/NewSpring/Holtzman/blob/add-json-serializer/imports/components/buttons/__tests__/small.js#L21) to the test where it fails. \r\n\r\nMy serializer is located [here](https://github.com/NewSpring/Holtzman/blob/add-json-serializer/imports/util/serializer/index.js)\r\n\r\nTo run the test, just install with `yarn` or `npm i` and run `npm test`"}}
{"actor":{"display_login":"JakeDawkins"}}