Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Sure they are.

  > 2) the require/import paths are not like '../../../../../' (which is awkward to reason about)
  > or requiring alias resolver configurations (which are environment-specific and fragile)
Compare writing an import path within a test of `import Button from '../Button'` to `import Button from '../../../../src/features/abc/components/Button'`. The latter requires you to count the directories in the path and replace each with '..'. This is a pointless waste of mental energy, and the former solution removes the need to do it.

The other solution as I described is to use things like aliases but this causes you to create complex configuration for your tests [0] which must be maintained and means your test are now dependent on this environment.

If this is just an opinion, please demonstrate that it's incorrect.

  > (3) you are not maintaining an extra directory
  > structure which could diverge by accident.
You are suggesting to me that `src/features/abc/components/Button.js` and `test/features/abc/components/Button.js` are not separate file-system structures which can diverge?

Because they are separate directory structures it is possible for them to diverge. This is a basic implication from the fact that they are separate structures.

If somebody moves `src/features/abc/components/Button.js` to `src/features/def/components/Button.js` you are telling me that you will not need to make any changes at all to `test/features/abc/components/Button.js`?

[0] https://github.com/trayio/babel-plugin-webpack-alias/issues/...



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: