Why specs in source? #21
Comments
Honestly it's just personal preference and I've seen it go both ways. My team follows the in-src test files, and I'm a fan of it just because it helps me keep them organized without duplicating folder structure. It has the additional benefit of making requires a bit more natural as well (imo). I could try to add some configuration so that karma also looks for tests in a |
Interesting. Perhaps I'll try it on a project to see how I like it. I always like learning how other teams operate and I think the pain points you noted are well taken. I don't think you need to make those changes as it is easy for someone to make those customizations if they prefer. Your docs mention this convention, although a bit passively. If you do anything, perhaps just adding a top level section like "Personal Conventions" or whatever in the README that more explicitly calls this out and which files to mod if someone prefers a different structure. (Same for styles). Again, I think it is fine as is. |
Yeah definitely, there's benefits to either system - I should probably do more experimenting with the other side of things because I've never given it much of a chance. As far as the documentation, that's a good idea. I've really been wanting to flesh out the README for a while now so that people can find their way around customizing the kit. My problem with a lot of the other boilerplates out there is how opinionated they are, something I've been trying to avoid, and better documentation would definitely help alleviate that with this repo. Thanks for the thoughts/advice! |
Another question I was wondering about. What's the reason for calling everything index.js (or index.jsx if it's a component)? In my IDE (Webstorm) I use "goto file" all the time. In my apps I use for instance userstore.js, user.jsx etc, so I just start typing "user" and I see all the files. Here it's a bit trickier since I have to type the path instead of the filename. In my humble opinion I prefer (as much as possible) unique files, so you know in your team if you're talking about a file which one it is exactly. |
@jonaswindey I had the same initial reaction. I think the purpose is for I also prefer your approach and so am renaming them, but I'd be curious to hear the author's perspective in case there are other benefits. |
@jonaswindey this is a comment I've heard a few times now, and it's completely valid. In fact, I will probably be updating the starter kit to follow that sort of naming convention - or I'm at least leaning heavily towards it. It stems from how my team develops, where we build all of our components as isolated npm packages. As a result, it's easy to keep track of files since the scope of a package is pretty small. Contrast this with an all-local starter kit such as this one, it can get a bit cumbersome to have a bunch of One benefit of keeping the
So importing this component can simply be: import MyComponent from 'components/my-component'; If you were to keep this structure but adopt a unique file naming convention, those imports would instead look like this: import MyComponent from 'components/my-component/my-component'; So you basically have 3 options: a. keep the current structure with The latter option gets rid of the redundant import statements, but ends up cluttering up your project once components start to accumulate additional files. For the sake of the starter kit, I'd probably pick option b and just deal with the redundancy. What are your thoughts on this @lifehackett and @jonaswindey? Also, now that the starter kit has been reduced to no longer include a bunch of example components, the effects of this style are far less noticeable, so I'm not sure whether or not it warrants a change. |
Now that you mention that you develop each component as its own npm package the structure makes more sense. So the approach I typically do is probably a derivative of c. I create subdirectories for a feature instead of a component.
Now perhaps profile as a container/frame should go somewhere else, and perhaps you wouldn't have The main difference is that I don't typically have the spec and style files in the same directory as the component and including those might start to get messy with my structure. I guess you could go another layer down
This is roughly equivalent to your hierarchy now. I think option a is the least desirable when developing as entire project (as opposed to individual packages) for the reasons @jonaswindey described. Options b and c each have their own smells as @davezuko pointed out; I think I slightly prefer b as well, unless you can think of a way to make the feature approach work in conjunction with the specs and styles in the same folder. |
The feature-focused structure makes sense, I've just never worked on a project that's laid out in that way so it honestly never crossed my mind. Now that you describe that folder structure, separating tests out from the I think for now switching to something close to option b is the best course of action, and hopefully the project remains configurable enough that if people want to take it a different direction they can. I'll look into making the relevant changes tonight or tomorrow. |
I just committed a branch to update the directory structure and naming conventions within src. I ended up following something a bit closer to option c simply because, with the todo example gone, there just aren't that many files. |
Merged structural changes with 238e9be |
I'm curious about your decision to embed your
.spec
files in the/src
directory. I haven't used (or seen) this setup before. IMO it pollutes the source files. It is easy to change the config for a different setup, but I'd be curious as to why you prefer this approach.The text was updated successfully, but these errors were encountered: