6 ms·
If they're using something like create-react-app, it may force that structure on them. I remember in earlier versions it was harder to configure other folders t
by notapenny 5y ago
If they're using something like create-react-app, it may force that structure on them. I remember in earlier versions it was harder to configure other folders to put tests in. I prefer your ideal structure as well, if you're going to co-locate files relating to Button, do it properly, makes it much easier to find things and in this case see if there are tests for your component.
- azemetre 5y agohmm. I honestly never used CRA outside of an interview assessment and don't really remember much. Early on in my web career I was encouraged to create my own scaffolding tools, that practice just always stuck with me. Kinda curious to learn how they enforced directory structures. I know now they co-locate tests, but IIRC CRA always used jest and with jest you just set the globs you want to use in the config file. Hardly hardcoded or strictly enforced, but I could be wrong.
- notapenny 5y agoCould also be that I'm remembering it wrong, but I recall having some issues with CRA and structuring tests at some point. In any case, CRA sets up a separate src and test folder, so I guess a lot of people just think they should structure their tests that way.
- mikewhy 5y agoCRA doesn't enforce any structure, outside of "code lives in arc/ and public files go in public/" The default templates are just a single folder, with tests located adjacent to their source files. CRA configures jest to look for test files in arc/, but let's users override that. https://github.com/facebook/create-react-app/tree/main/packages/cra-template/template https://github.com/facebook/create-react-app/tree/main/packa... https://github.com/facebook/create-react-app/tree/main/packages/cra-template/template https://github.com/facebook/create-react-app/tree/main/packa...