Do you want to request a feature or report a bug?
Bug.
What is the current behavior?
If I create a snapshot, but later exit the test before the snapshot assertion, the error message is confusing.
Start with https://repl.it/GKoO/3. Then change the test to exit early:
it('should add two numbers', () => {
return;
expect(3).toMatchSnapshot();
});
In 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.)
If you run the tests now, you will see:
Jest v18.0.0, node v6.7 linux/amd64
PASS ./add-test.js
FAIL __snapshots__/add-test.js.snap
● Test suite failed to run
Your test suite must contain at least one test.
at onResult (../../usr/local/lib/node_modules/jest-cli/build/TestRunner.js:192:18)
Snapshot Summary
› 1 obsolete snapshot found, re-run with `-u` to remove them.
Test Suites: 1 failed, 1 passed, 2 total
Tests: 1 passed, 1 total
Snapshots: 0 total
Time: 0.333s, estimated 1s
Ran all test suites.
What is the expected behavior?
I would expect this part to not be printed:
FAIL __snapshots__/add-test.js.snap
● Test suite failed to run
Your test suite must contain at least one test.
at onResult (../../usr/local/lib/node_modules/jest-cli/build/TestRunner.js:192:18)
It 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.
Please provide your exact Jest configuration and mention your Jest, node, yarn/npm version and operating system.
Jest 19.0.1, Node 6.0.0, npm 3.8.6.
If I later press u following the suggestion to remove the missing snapshot (though it's not what I want), I get this error:
PASS src/renderers/shared/__tests__/ReactDebugFiberPerf-test.js
FAIL src/renderers/shared/__tests__/__snapshots__/ReactDebugFiberPerf-test.js.snap
● Test suite failed to run
ENOENT: no such file or directory, stat '/Users/gaearon/p/react/src/renderers/shared/__tests__/__snapshots__/ReactDebugFiberPerf-test.js.snap'
at Error (native)
at Object.fs.statSync (fs.js:981:18)
at Object.statSync (node_modules/graceful-fs/polyfills.js:297:22)
Snapshot Summary
› 1 obsolete snapshot file removed.
Test Suites: 1 failed, 1 passed, 2 total
Tests: 1 passed, 1 total
Snapshots: 0 total
Time: 0.127s, estimated 1s
It's because your testRegex is broken and it tries to run .snap files as tests.
Why can I reproduce this on repl though?

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.
I linked to repl.it repro in my post.
OK, this is because Jest repl has this setting:
"testRegex": ".*-test.js",
(Just like my project 😄 )
The correct setting would be:
"testRegex": ".*-test\.js$",
This is the default replit Jest config:

I pinged @amasad about this.
Ah, I see, sorry about that. We also have jest-repl which is a separate project. Thanks @gaearon.
Oops. N00b. Will push a fix today.
Most helpful comment
I linked to repl.it repro in my post.
OK, this is because Jest repl has this setting:
(Just like my project 😄 )
The correct setting would be: