Re:Delightful React file/directory structure
by notapenny on Tuesday March 15, 2022 @01:33PM
(#30688267)
Could 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.
Re:Delightful React file/directory structure
by mikewhy on Thursday March 17, 2022 @02:36PM
(#30714439)
CRA 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/packa...
https://github.com/facebook/create-react-app/tree/main/packa...
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.