benawad/destiny

Test File Location

Opened this issue · 1 comments

When using jest, it's common practice to name the test files ComponentName.test.js and put them in an __tests__ directory next to the component. Since these tests import the component and the component does not import the tests, destiny naturally tends to flip the directory structure around. This is unfortunate as it makes it look like the test is the "entry point" rather than a supporting file. Another example of the same pattern is storybook stories, that are typically files that end in .story.js and should probably be handled in the same way as jest tests.

Ideas:

  1. We could treat anything that has a "sub extension" i.e. some-file.some-extenstion.js as being a "supporting file" and keep it beneath the component. Not sure how you do the __tests__/__stories__ bit, but maybe it would be sufficient just to exclude it from the graph and then put it next to the file?
  2. We could accept a config for what files should be treated specially.

I think the best option might be to force people to abandon the __tests__/__stories__ folders and just have

Input:

- MyComponent.js
- __tests__/MyComponent.test.js
- __stories__/MyComponent.story.js

Output:

- MyComponent.js
- MyComponent.test.js
- MyComponent.story.js

but crucially never:

- shared/MyComponent.js
- MyComponent.test.js
- MyComponent.story.js

I just saw #107 which I think is closely related to this.