department-of-veterans-affairs / va.gov-team

Public resources for building on and in support of VA.gov. Visit complete Knowledge Hub:
https://depo-platform-documentation.scrollhelp.site/index.html
282 stars 203 forks source link

Move unit tests adjacent to the source of the system under testing #95023

Open JunTaoLuo opened 6 days ago

JunTaoLuo commented 6 days ago

As part of the effort to improve our unit tests, we've decided to move unit tests to the same directory as the source file of the system under testing.

For example:

src\applications\vaos\components
\- subdirectoryA
  \- SubcomponentA.jsx
   - SubcomponentA.unit.spec.js
 - Component1.jsx
 - Component1.unit.spec

Primarily, this provides the benefit of making it easier to find the associated test file for each component and to identify which source files is missing associated tests.

Note that naming of the unit tests should:

Definition of Done

JunTaoLuo commented 6 days ago

One open question is where should the test utilities (e.g. mocks, helpers) be located? If it is placed in the same directory as the source and unit test files, it becomes a little more difficult to differentiate between source files and test utilities. We need to test this out to ensure the coverage tool recognizes test utilities correctly.

cc @simiadebowale @vbahinwillit

Bren22va commented 5 days ago

Hey team! Please add your planning poker estimate with Zenhub @cferris32 @jenniemc @JunTaoLuo @ryanshaw @simiadebowale @vbahinwillit