Skip to content
This repository has been archived by the owner on Aug 30, 2019. It is now read-only.

Proposal: Move tests inside component directories #307

Open
fahad19 opened this issue Jan 10, 2018 · 10 comments
Open

Proposal: Move tests inside component directories #307

fahad19 opened this issue Jan 10, 2018 · 10 comments
Labels

Comments

@fahad19
Copy link

fahad19 commented Jan 10, 2018

Currently

  • Components are written in ./components/foo directory
  • Tests are found in ./tests/unit/foo

Proposal

  • Move source and tests in one place.

Example

Example directory structure:

├── components/
│   ├── Button/
│      ├── index.js
│      ├── index.spec.js
│      ├── snapshots/
└── package.json

Why?

Everything related to a particular component can be found in one place. Developer doesn't have to jump around to find tests. Also easier to see if a certain component is missing tests quickly.

@yurist38
Copy link
Contributor

I like this approach as well! But, in case we have many files in a folder (i.e. some sub-components) I prefer to have test files in the sub-folder. I see that, for example, carousel component has many js files in its folder and I don't really want to see tests files beside them. As for me, it will add a mess to the files structure. I would suggest having a subfolder of tests.

@asci
Copy link
Contributor

asci commented Jan 11, 2018

Or sub-folders for sub-components?

@yurist38
Copy link
Contributor

yurist38 commented Jan 11, 2018

@asci or like that. Both options are fine for me. And one more thing: I see an inconsistency in subcomponents structure, i.e. calendar component has subfolders but carousel doesn't. I think we should choose the single way to go and refactor all components (could be done in one step together with moving tests).

@leandrooriente
Copy link
Contributor

@asci approach seems good to me 👍

+ Components
  + DropDown
    - DropDown.js
    - DropDown.scss
    - DropDown.spec.js
    - index.js
    + Option
      - Option.js
      - Option.scss
      - Option.spec.js
      - index.js   
  + Button
    - Button.js
    - Button.scss
    - Button.spec.js
    - index.js

@leandrooriente
Copy link
Contributor

What do you think @iwwwi, @rbardini and @froskie?

@rbardini
Copy link
Contributor

rbardini commented Mar 7, 2018

👍 from me, tests should live alongside the code. Also agree with @asci suggestion of subfolders for scoped components.

@AlleeX
Copy link
Contributor

AlleeX commented Mar 7, 2018

One remark from me

+ Components
  + DropDown
    +  __tests__
      - __snapshots__
      - DropDown.onChange.spec.js
      - DropDown.render.spec.js
    - DropDown.js
    - DropDown.scss
    - index.js

@rbardini
Copy link
Contributor

rbardini commented Mar 7, 2018

@AlleeX could you elaborate why separate test files per component method?

@leandrooriente
Copy link
Contributor

I just created a PR using this new directory structure.
It's still working in progress but it's possible to have a better overview of how the project would look.

@iwwwi
Copy link
Contributor

iwwwi commented Mar 7, 2018

I am also fine with adding the tests with the components folder structure. Subfolders are also good option for subcomponents. Also having tests folder in the components i think is great idea, simply from the perspective if some component's test get too long to be in 1 file, it can be split in multiple files as @AlleeX suggested...

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

7 participants