Skip to content
This repository has been archived by the owner on May 17, 2019. It is now read-only.

Support files other than tests inside of __tests__ folders #355

Open
KevinGrandon opened this issue May 9, 2018 · 3 comments
Open

Support files other than tests inside of __tests__ folders #355

KevinGrandon opened this issue May 9, 2018 · 3 comments

Comments

@KevinGrandon
Copy link
Contributor

Type of issue

Feature request

Description

Many developers have a need for fixtures and helper libraries for running test logic. With the current naming scheme that we have for universal tests, developers can't easily have additional utilities inside of the __tests__ folder.

Current behavior

Any files ending in .js inside of a __tests__ folder will attempt to execute as a jest test. When run, jest will fail with an error like:

● Test suite failed to run
Your test suite must contain at least one test.

Expected behavior

You should be able to run tests and ignore utilities, helpers and fixtures.

Possible fixes

Whitelist a support folder

Any files within this folder would not be considered tests. If there are tests in a folder named __tests__/support this would be a breaking change, but we might consider this one to be non-breaking as that seems pretty unlikely.

Reconsider universal test naming scheme

Rename universal tests to something like myTest.global.js or myTest.universal.js. We would then support myTest.(universal|node|browser).js. Breaking change.

@rtsao
Copy link
Member

rtsao commented May 9, 2018

Shouldn't only root files inside a given __tests__ directory be considered tests? For example:

  • __tests__/test.js
  • __tests__/foo/nontest.js
  • foo/__tests__/test.js
  • foo/__tests__/foo/nontest.js

Having a specific subdirectory for non-tests seems odd, shouldn't it be every subdirectory?

@KevinGrandon
Copy link
Contributor Author

Shouldn't only root files inside a given tests directory be considered tests? For example:

This is one convention that we can look at as well. Because we encourage co-locating tests with code, folks shouldn't need nested directory structures for tests.

@chrisdothtml
Copy link
Member

How do you feel about using the underscore notation for helper files? It would just exclude any files that begin with an underscore. e.g.

| __tests__/_utils.js
| __tests__/test.js

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants