Feeling really dumb here. I can't find any information in the docs to describe how Jest finds tests, or where I should put all my test files, or what filename conventions to use. The Getting Started example uses sum.js and sum.test.js, does that mean I should write all my tests in files right beside the source file with the convention [filename].test.js? It would be nice if this were explicitly stated somewhere.
Searching through Google I also found that there's a __tests__ directory that can be used alternatively. Does Jest parse every JS file in __tests__ directories, or do I need to follow some naming convention? I can't find reference to __tests__ anywhere in the docs.
Can someone create a section in Getting Started to explain the different options here and the recommended approach?
I understand the docs may want to take an unopinionated stance, but for newcomers having some type of default will lower the barrier to adopting new technologies.
Here you go :) http://facebook.github.io/jest/docs/configuration.html#testregex-string
And this is a small visualisation of this regex:
โโโ __tests__
โ โโโ component.spec.js # test
โ โโโ anything # test
โโโ package.json # not test
โโโ foo.test.js # test
โโโ bar.spec.jsx # test
โโโ component.js # not test
I think it's a great opportunity for a first contribution. Feel free to send a PR we'd love to review and merge it!
Most helpful comment
Here you go :) http://facebook.github.io/jest/docs/configuration.html#testregex-string
And this is a small visualisation of this regex:
I think it's a great opportunity for a first contribution. Feel free to send a PR we'd love to review and merge it!