-
-
Notifications
You must be signed in to change notification settings - Fork 526
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
feat: add support for test files colocated with models #1187
feat: add support for test files colocated with models #1187
Conversation
i looked for a file with relevant test cases for this code but couldn't find it. If anyone knows where this logic is tested i'm happy to add additional test cases in there |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm also not sure how to test this, but I think we can look into that later. Thanks for this PR!
🎉 This PR is included in version 6.6.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Pull Request check-list
Please make sure to review and check all of these items:
npm run test
pass with this change (including linting)?Description of change
The models/index.js file is an auto-generated file used to automatically register all models from the models folder
It works under the assumption that the only files you have in your /models folder are models.
This works for most of the cases, but it causes an issue for projects using tests colocated with the tested file, e.g.
for such cases, if you want to add unit tests, you would have to either move to a symmetric /tests folder that replicates the structure of your project (for example as this project does), or follow this approach only for the models folder (quite inconsistent), or not write tests for models (quite bad)
This PR addresses the issue by adding a condition that will skip filenames containing
.test.js
.