{"action":"created","issue":{"url":"https://api.github.com/repos/facebook/jest/issues/3090","repository_url":"https://api.github.com/repos/facebook/jest","labels_url":"https://api.github.com/repos/facebook/jest/issues/3090/labels{/name}","comments_url":"https://api.github.com/repos/facebook/jest/issues/3090/comments","events_url":"https://api.github.com/repos/facebook/jest/issues/3090/events","html_url":"https://github.com/facebook/jest/issues/3090","id":212462096,"number":3090,"title":"Confusing \"Your test suite must contain at least one test\" because of an unused snapshot","user":{"login":"gaearon","id":810438,"avatar_url":"https://avatars3.githubusercontent.com/u/810438?v=3","gravatar_id":"","url":"https://api.github.com/users/gaearon","html_url":"https://github.com/gaearon","followers_url":"https://api.github.com/users/gaearon/followers","following_url":"https://api.github.com/users/gaearon/following{/other_user}","gists_url":"https://api.github.com/users/gaearon/gists{/gist_id}","starred_url":"https://api.github.com/users/gaearon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gaearon/subscriptions","organizations_url":"https://api.github.com/users/gaearon/orgs","repos_url":"https://api.github.com/users/gaearon/repos","events_url":"https://api.github.com/users/gaearon/events{/privacy}","received_events_url":"https://api.github.com/users/gaearon/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2017-03-07T15:14:48Z","updated_at":"2017-03-07T16:09:28Z","closed_at":"2017-03-07T16:06:43Z","body":"**Do you want to request a *feature* or report a *bug*?**\r\n\r\nBug.\r\n\r\n**What is the current behavior?**\r\n\r\nIf I create a snapshot, but later exit the test before the snapshot assertion, the error message is confusing.\r\n\r\nStart with https://repl.it/GKoO/3. Then change the test to exit early:\r\n\r\n```js\r\n  it('should add two numbers', () => {\r\n    return;\r\n    expect(3).toMatchSnapshot();\r\n  });\r\n```\r\n\r\nIn a real use case, I exit based on a feature flag. (I have to do this inside the test because Jest won't let me *define* tests conditionally since my suite would become empty when the feature flag is off.)\r\n\r\nIf you run the tests now, you will see:\r\n\r\n```\r\n\r\nJest v18.0.0, node v6.7 linux/amd64\r\n   \r\n PASS  ./add-test.js\r\n FAIL  __snapshots__/add-test.js.snap\r\n  ● Test suite failed to run\r\n\r\n    Your test suite must contain at least one test.\r\n      \r\n      at onResult (../../usr/local/lib/node_modules/jest-cli/build/TestRunner.js:192:18)\r\n\r\nSnapshot Summary\r\n › 1 obsolete snapshot found, re-run with `-u` to remove them.\r\n\r\nTest Suites: 1 failed, 1 passed, 2 total\r\nTests:       1 passed, 1 total\r\nSnapshots:   0 total\r\nTime:        0.333s, estimated 1s\r\nRan all test suites.\r\n```\r\n\r\n**What is the expected behavior?**\r\n\r\nI would expect this part to not be printed:\r\n\r\n```\r\n FAIL  __snapshots__/add-test.js.snap\r\n  ● Test suite failed to run\r\n\r\n    Your test suite must contain at least one test.\r\n      \r\n      at onResult (../../usr/local/lib/node_modules/jest-cli/build/TestRunner.js:192:18)\r\n```\r\n\r\nIt took me a while to see `.snap` at the end of the file. Jest snapshots might be represented as test suites internally, but it’s confusing to me as a user. I thought Jest just fails to see tests in my suite for some reason.\r\n\r\n**Please provide your exact Jest configuration and mention your Jest, node, yarn/npm version and operating system.**\r\n\r\nJest 19.0.1, Node 6.0.0, npm 3.8.6."},"comment":{"url":"https://api.github.com/repos/facebook/jest/issues/comments/284767389","html_url":"https://github.com/facebook/jest/issues/3090#issuecomment-284767389","issue_url":"https://api.github.com/repos/facebook/jest/issues/3090","id":284767389,"user":{"login":"cpojer","id":13352,"avatar_url":"https://avatars3.githubusercontent.com/u/13352?v=3","gravatar_id":"","url":"https://api.github.com/users/cpojer","html_url":"https://github.com/cpojer","followers_url":"https://api.github.com/users/cpojer/followers","following_url":"https://api.github.com/users/cpojer/following{/other_user}","gists_url":"https://api.github.com/users/cpojer/gists{/gist_id}","starred_url":"https://api.github.com/users/cpojer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cpojer/subscriptions","organizations_url":"https://api.github.com/users/cpojer/orgs","repos_url":"https://api.github.com/users/cpojer/repos","events_url":"https://api.github.com/users/cpojer/events{/privacy}","received_events_url":"https://api.github.com/users/cpojer/received_events","type":"User","site_admin":false},"created_at":"2017-03-07T16:09:28Z","updated_at":"2017-03-07T16:09:28Z","body":"What do you mean reproduce on repl? The problem is that snapshot files are not test files but they are regular JS files. Jest will run them as a test and then realize there are no tests defined in it."}}
{"actor":{"display_login":"cpojer"}}