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

Documentation does not contain file structure/naming conventions #3730

Closed
jeffreznik opened this issue Jun 3, 2017 · 2 comments · Fixed by #3758
Closed

Documentation does not contain file structure/naming conventions #3730

jeffreznik opened this issue Jun 3, 2017 · 2 comments · Fixed by #3758

Comments

@jeffreznik
Copy link

jeffreznik commented Jun 3, 2017

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.

@thymikee
Copy link
Collaborator

thymikee commented Jun 3, 2017

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!

@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 13, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants