mojaloop / design-authority-project

This is the Issue and Decision Log for tracking mojaloop and related Designs
1 stars 2 forks source link

Exclude models folder from unit test coverage checks for all repositories #64

Closed claudio-viola closed 2 years ago

claudio-viola commented 3 years ago

Request:

Currently unit test coverage checks for the repositories in mojaloop are set to a minimum of 90% With the following or similar setup

check-coverage: true
per-file: true
lines: 90
statements: 90
functions: 90
branches: 90
all: true
include: [
  "src/**/*.js"
]
instrument: true
reporter: [
  "lcov",
  "text-summary",
  "html"
]
exclude: [
  "**/node_modules/**",
  '**/migrations/**',
  '**/docs/**',
]

The proposal is to exclude all the files that perform database calls while making sure that those files only make database calls and perform no logic. Two steps 1) add /models/ in the exclude section in the .nyrc file (above) 2) make sure any code added into the models section only makes call to the database (no logic) to be added to a peer review check list.

Rationale: When unit testing modules or functions that perform a lot of complex database calls using knex , the corresponding unit testing results in a complex, expensive and time consuming practice that adds very little to no value. Everything is being mocked and no logic is being tested except the fact that knex is called. The result of writing such unit test is that the code, both the unit test and source code is hard to verify, hard to change once unit tests are code, and hard to validate without actually providing any sort of protection that we are writing the right code or fulfilling the requirements of a feature being implemented. The proposal will help us save valuable time from our contributors. This time could be used for testing the same code at a different level / step in the process.

Existing example function to be used as a reference https://github.com/mojaloop/central-settlement/blob/master/src/models/settlementWindow/facade.js#L79 and its corresponding unit test https://github.com/mojaloop/central-settlement/blob/master/test/unit/models/settlementWindow/facade.test.js

Artifacts:

Decision(s):

Follow-up:

Dependencies:

Accountability:

Notes:

NicoDuvenage commented 3 years ago

Regarding this topic, a decision has been reached to exclude the "models" folder from any unit test coverage for all repositories, given that no business logic is contained therein. If that folder does in fact contain business logic, the code must be refactored to move it to the appropriate place.