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

Test File Location #109

Open
ForbesLindesay opened this issue Apr 23, 2020 · 1 comment
Open

Test File Location #109

ForbesLindesay opened this issue Apr 23, 2020 · 1 comment
Labels
enhancement New feature or request

Comments

@ForbesLindesay
Copy link

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
@ForbesLindesay
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants