PhilanthropyDataCommons / service

A project for collecting and serving public information associated with grant applications
GNU Affero General Public License v3.0
9 stars 2 forks source link

Ensure test setup and teardown does not count towards test coverage #1267

Open bickelj opened 1 month ago

bickelj commented 1 month ago

During #1262, while working in the /changemakers integration tests, I figured that beforeEach calls (and transitive calls from within that) would not be marked as "covered", likewise for blocks/statements marked with /* istanbul ignore next */. However, even after peppering test setups with /* istanbul ignore next */, the coverage is identical to before such peppering, and I see a lot of unrelated/untested code being marked as "covered" inaccurately.

Example coverage report when running only the changemakers integration tests with coverage, both before and after adding ignore next statements:

-------------------------------------------|---------|----------|---------|---------|-------------------
File                                       | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s 
-------------------------------------------|---------|----------|---------|---------|-------------------
All files                                  |   59.36 |    21.17 |   30.41 |   58.53 |                   
 src                                       |    60.6 |    13.63 |   33.33 |   58.33 |                   
  ajv.ts                                   |   88.88 |      100 |       0 |   88.88 | 13                
  app.ts                                   |     100 |      100 |     100 |     100 |                   
  config.ts                                |    90.9 |        0 |     100 |   88.88 | 13                
  fieldValidation.ts                       |   57.89 |        0 |       0 |   58.82 | 33-45             
  index.ts                                 |       0 |        0 |       0 |       0 | 1-38              
  jobQueue.ts                              |   51.51 |    28.57 |      25 |   46.42 | 14-28,33-44,55,66 
  logger.ts                                |     100 |       50 |     100 |     100 | 9                 
  s3Client.ts                              |     100 |      100 |     100 |     100 |                   
 src/auth                                  |     100 |      100 |     100 |     100 |                   
  jwtOptions.ts                            |     100 |      100 |     100 |     100 |                   
 src/database                              |     100 |        0 |     100 |     100 |                   
  db.ts                                    |     100 |      100 |     100 |     100 |                   
  index.ts                                 |     100 |      100 |     100 |     100 |                   
  migrate.ts                               |     100 |        0 |     100 |     100 | 9                 
 src/database/operations                   |     100 |      100 |     100 |     100 |                   
  index.ts                                 |     100 |      100 |     100 |     100 |                   
 ...abase/operations/applicationFormFields |   64.28 |        0 |      25 |      64 |                   
  createApplicationFormField.ts            |   88.88 |        0 |     100 |   88.88 | 23                
  index.ts                                 |     100 |      100 |     100 |     100 |                   
  loadApplicationFormField.ts              |   44.44 |        0 |       0 |    37.5 | 8-21              
  loadApplicationFormFieldBundle.ts        |   42.85 |      100 |       0 |      40 | 13-23             
 src/database/operations/applicationForms  |   64.28 |        0 |      25 |    62.5 |                   
  createApplicationForm.ts                 |   88.88 |        0 |     100 |    87.5 | 20                
  index.ts                                 |     100 |      100 |     100 |     100 |                   
  loadApplicationForm.ts                   |   44.44 |        0 |       0 |    37.5 | 8-21              
  loadApplicationFormBundle.ts             |   42.85 |      100 |       0 |      40 | 8-17              
 ...abase/operations/baseFieldLocalization |   47.36 |        0 |       0 |   47.05 |                   
  createOrUpdateBaseFieldLocalizations.ts  |      40 |        0 |       0 |   33.33 | 12-32             
  index.ts                                 |     100 |      100 |     100 |     100 |                   
  ...ldLocalizationsBundleByBaseFieldId.ts |   42.85 |      100 |       0 |      50 | 13-24             
 src/database/operations/baseFields        |   62.16 |       25 |      20 |   57.57 |                   
  createBaseField.ts                       |   88.88 |       50 |     100 |    87.5 | 25                
  index.ts                                 |     100 |      100 |     100 |     100 |                   
  loadBaseField.ts                         |   44.44 |        0 |       0 |    37.5 | 6-19              
  loadBaseFields.ts                        |      60 |      100 |       0 |      50 | 5-6               
  updateBaseField.ts                       |      40 |        0 |       0 |   33.33 | 13-32             
 src/database/operations/bulkUploads       |   42.85 |        0 |       0 |   37.83 |                   
  createBulkUpload.ts                      |   33.33 |        0 |       0 |      25 | 11-29             
  index.ts                                 |     100 |      100 |     100 |     100 |                   
  loadBulkUpload.ts                        |   44.44 |        0 |       0 |    37.5 | 6-19              
  loadBulkUploadBundle.ts                  |   33.33 |      100 |       0 |   28.57 | 16-31             
  updateBulkUpload.ts                      |   36.36 |        0 |       0 |      30 | 13-36             
 ...tabase/operations/changemakerProposals |   72.22 |        0 |   33.33 |   73.33 |                   
  createChangemakerProposal.ts             |   88.88 |        0 |     100 |    87.5 | 21                
  index.ts                                 |     100 |      100 |     100 |     100 |                   
  loadChangemakerProposalBundle.ts         |   42.85 |      100 |       0 |      40 | 14-25             
 src/database/operations/changemakers      |   85.71 |    44.44 |      80 |   83.78 |                   
  createChangemaker.ts                     |   88.88 |    33.33 |     100 |    87.5 | 21                
  index.ts                                 |     100 |      100 |     100 |     100 |                   
  loadChangemaker.ts                       |     100 |      100 |     100 |     100 |                   
  loadChangemakerBundle.ts                 |     100 |      100 |     100 |     100 |                   
  loadChangemakerByTaxId.ts                |   44.44 |        0 |       0 |    37.5 | 8-23              
 src/database/operations/dataProviders     |   60.52 |    11.11 |      20 |   62.16 |                   
  createOrUpdateDataProvider.ts            |   88.88 |    33.33 |     100 |   88.88 | 21                
  index.ts                                 |     100 |      100 |     100 |     100 |                   
  loadDataProvider.ts                      |   44.44 |        0 |       0 |   44.44 | 8-21              
  loadDataProviderBundle.ts                |   42.85 |      100 |       0 |      50 | 8-17              
  loadSystemDataProvider.ts                |   44.44 |        0 |       0 |   44.44 | 6-17              
 src/database/operations/funders           |   64.28 |    16.66 |      25 |   65.38 |                   
  createOrUpdateFunder.ts                  |   88.88 |    33.33 |     100 |   88.88 | 21                
  index.ts                                 |     100 |      100 |     100 |     100 |                   
  loadFunder.ts                            |   44.44 |        0 |       0 |    37.5 | 6-19              
  loadFunderBundle.ts                      |   42.85 |      100 |       0 |      50 | 8-17              
 src/database/operations/generic           |   90.47 |        0 |     100 |   89.47 |                   
  index.ts                                 |     100 |      100 |     100 |     100 |                   
  loadBundle.ts                            |     100 |      100 |     100 |     100 |                   
  loadTableMetrics.ts                      |   83.33 |        0 |     100 |   81.81 | 17,23             
 src/database/operations/opportunities     |   64.28 |    16.66 |      25 |   65.38 |                   
  createOpportunity.ts                     |   88.88 |    33.33 |     100 |    87.5 | 21                
  index.ts                                 |     100 |      100 |     100 |     100 |                   
  loadOpportunity.ts                       |   44.44 |        0 |       0 |   44.44 | 6-19              
  loadOpportunityBundle.ts                 |   42.85 |      100 |       0 |      50 | 8-17              
 ...atabase/operations/proposalFieldValues |      90 |       50 |     100 |      90 |                   
  createProposalFieldValue.ts              |   88.88 |       50 |     100 |   88.88 | 31                
  index.ts                                 |     100 |      100 |     100 |     100 |                   
 src/database/operations/proposalVersions  |      90 |       50 |     100 |      90 |                   
  createProposalVersion.ts                 |   88.88 |       50 |     100 |   88.88 | 24                
  index.ts                                 |     100 |      100 |     100 |     100 |                   
 src/database/operations/proposals         |    57.5 |        0 |      20 |   54.28 |                   
  assertProposalAuthorization.ts           |   44.44 |        0 |       0 |    37.5 | 9-19              
  createProposal.ts                        |   88.88 |        0 |     100 |    87.5 | 19                
  index.ts                                 |     100 |      100 |     100 |     100 |                   
  loadProposal.ts                          |   44.44 |        0 |       0 |    37.5 | 6-16              
  loadProposalBundle.ts                    |   33.33 |      100 |       0 |   28.57 | 18-35             
 src/database/operations/sources           |   71.42 |    58.33 |   33.33 |   71.11 |                   
  assertSourceExists.ts                    |   57.14 |        0 |       0 |      50 | 6-11              
  createSource.ts                          |   91.66 |    77.77 |     100 |    90.9 | 28                
  index.ts                                 |     100 |      100 |     100 |     100 |                   
  loadSource.ts                            |   44.44 |        0 |       0 |    37.5 | 6-16              
  loadSourceBundle.ts                      |   42.85 |      100 |       0 |      50 | 8-17              
  loadSystemSource.ts                      |   88.88 |        0 |     100 |   88.88 | 12                
 src/database/operations/users             |   78.04 |    28.57 |      60 |   78.37 |                   
  createUser.ts                            |   88.88 |    33.33 |     100 |    87.5 | 11                
  index.ts                                 |     100 |      100 |     100 |     100 |                   
  loadSystemUser.ts                        |   88.88 |        0 |     100 |   88.88 | 12                
  loadUserBundle.ts                        |   33.33 |      100 |       0 |   28.57 | 16-31             
  loadUserByKeycloakUserId.ts              |      90 |    33.33 |     100 |   88.88 | 17                
 src/database/parameters                   |    90.9 |        0 |     100 |      90 |                   
  getLimitValues.ts                        |      90 |        0 |     100 |   88.88 | 14                
  index.ts                                 |     100 |      100 |     100 |     100 |                   
 src/errors                                |   86.66 |      100 |      75 |   86.66 |                   
  DatabaseError.ts                         |     100 |      100 |     100 |     100 |                   
  FailedMiddlewareError.ts                 |     100 |      100 |     100 |     100 |                   
  InputConflictError.ts                    |      25 |      100 |       0 |      25 | 12-14             
  InputValidationError.ts                  |     100 |      100 |     100 |     100 |                   
  InternalValidationError.ts               |     100 |      100 |     100 |     100 |                   
  JobQueueStateError.ts                    |       0 |      100 |     100 |       0 | 1                 
  NotFoundError.ts                         |     100 |      100 |     100 |     100 |                   
  UnauthorizedError.ts                     |     100 |      100 |     100 |     100 |                   
  ValidationError.ts                       |     100 |      100 |     100 |     100 |                   
  index.ts                                 |     100 |      100 |     100 |     100 |                   
 src/handlers                              |   25.29 |     5.96 |    7.43 |   25.29 |                   
  applicationFormsHandlers.ts              |    18.6 |        0 |       0 |    18.6 | ...3,42-56,65-107 
  baseFieldsHandlers.ts                    |   13.75 |        0 |       0 |   13.75 | ...10-144,153-216 
  bulkUploadsHandlers.ts                   |   20.45 |        0 |       0 |   20.45 | 33-87,96-117      
  changemakerProposalsHandlers.ts          |   25.92 |        0 |       0 |   25.92 | 23-44,53-72       
  changemakersHandlers.ts                  |   81.57 |    69.23 |   88.88 |   81.57 | 43,61-65,86-87    
  dataProvidersHandlers.ts                 |   18.36 |        0 |       0 |   18.36 | ...1,50-66,75-108 
  fundersHandlers.ts                       |   18.36 |        0 |       0 |   18.36 | 22-37,42-58,63-96 
  opportunitiesHandlers.ts                 |   22.85 |        0 |       0 |   22.85 | 21-32,41-55,64-82 
  platformProviderResponsesHandlers.ts     |   35.48 |        0 |       0 |   35.48 | 30-61,90-121      
  presignedPostRequestsHandlers.ts         |      50 |        0 |       0 |      50 | 16,31-52          
  proposalVersionsHandlers.ts              |   13.55 |        0 |       0 |   13.55 | ...79-111,119-211 
  proposalsHandlers.ts                     |      25 |        0 |   11.11 |      25 | ...8,63-81,90-120 
  sourcesHandlers.ts                       |   19.04 |        0 |       0 |   19.04 | 22-48,53-68,73-87 
  usersHandlers.ts                         |      35 |        0 |       0 |      35 | 11-28             
 src/middleware                            |   76.81 |    42.85 |   82.35 |   76.64 |                   
  addRoleContext.ts                        |     100 |      100 |     100 |     100 |                   
  addUserContext.ts                        |   78.26 |       50 |      75 |   78.26 | 17-18,38-44,53    
  errorHandler.ts                          |   75.38 |    48.27 |     100 |      75 | ...,90,98,104,121 
  index.ts                                 |     100 |      100 |     100 |     100 |                   
  processJwt.ts                            |      80 |        0 |   66.66 |      80 | 18-20             
  requireAdministratorRole.ts              |      50 |        0 |       0 |      50 | 11-17             
  requireAuthentication.ts                 |   71.42 |    33.33 |     100 |   71.42 | 16-21,24-25       
 src/queryParameters                       |      80 |    28.57 |   66.66 |   78.94 |                   
  extractChangemakerParameters.ts          |      90 |    66.66 |     100 |      90 | 41                
  extractCreatedByParameters.ts            |   58.33 |        0 |       0 |   58.33 | 48-59             
  extractKeycloakUserIdParameters.ts       |   63.63 |        0 |       0 |   63.63 | 29-36             
  extractPaginationParameters.ts           |    87.5 |    57.14 |     100 |   85.71 | 11                
  extractProposalParameters.ts             |      90 |        0 |     100 |      90 | 31                
  extractSearchParameters.ts               |     100 |      100 |     100 |     100 |                   
  index.ts                                 |     100 |      100 |     100 |     100 |                   
 src/routers                               |     100 |      100 |     100 |     100 |                   
  applicationFormsRouter.ts                |     100 |      100 |     100 |     100 |                   
  baseFieldsRouter.ts                      |     100 |      100 |     100 |     100 |                   
  bulkUploadsRouter.ts                     |     100 |      100 |     100 |     100 |                   
  changemakerProposalsRouter.ts            |     100 |      100 |     100 |     100 |                   
  changemakersRouter.ts                    |     100 |      100 |     100 |     100 |                   
  dataProviderRouter.ts                    |     100 |      100 |     100 |     100 |                   
  documentationRouter.ts                   |     100 |      100 |     100 |     100 |                   
  fundersRouter.ts                         |     100 |      100 |     100 |     100 |                   
  index.ts                                 |     100 |      100 |     100 |     100 |                   
  opportunitiesRouter.ts                   |     100 |      100 |     100 |     100 |                   
  platformProviderResponsesRouter.ts       |     100 |      100 |     100 |     100 |                   
  presignedPostRequestsRouter.ts           |     100 |      100 |     100 |     100 |                   
  proposalVersionsRouter.ts                |     100 |      100 |     100 |     100 |                   
  proposalsRouter.ts                       |     100 |      100 |     100 |     100 |                   
  sourcesRouter.ts                         |     100 |      100 |     100 |     100 |                   
  usersRouter.ts                           |     100 |      100 |     100 |     100 |                   
 src/scripts                               |       0 |        0 |       0 |       0 |                   
  migrate.ts                               |       0 |        0 |       0 |       0 | 1-18              
 src/tasks                                 |   17.72 |        0 |       0 |   17.19 |                   
  index.ts                                 |     100 |      100 |     100 |     100 |                   
  processBulkUpload.ts                     |   17.19 |        0 |       0 |   16.66 | ...01-211,218-382 
 src/test                                  |   88.31 |    77.77 |   77.77 |   89.55 |                   
  harnessFunctions.ts                      |   93.54 |        0 |     100 |   92.85 | 7,12              
  mockGraphileWorker.ts                    |       0 |      100 |       0 |       0 | 1-5               
  mockJwt.ts                               |     100 |      100 |     100 |     100 |                   
  utils.ts                                 |   86.36 |      100 |      50 |    87.5 | 21-22             
 src/types                                 |   99.46 |    72.72 |     100 |   99.45 |                   
  ApplicationForm.ts                       |     100 |      100 |     100 |     100 |                   
  ApplicationFormField.ts                  |     100 |      100 |     100 |     100 |                   
  AuthContext.ts                           |     100 |      100 |     100 |     100 |                   
  BaseField.ts                             |     100 |      100 |     100 |     100 |                   
  BaseFieldLocalization.ts                 |     100 |      100 |     100 |     100 |                   
  BulkUpload.ts                            |     100 |      100 |     100 |     100 |                   
  Changemaker.ts                           |     100 |      100 |     100 |     100 |                   
  ChangemakerProposal.ts                   |     100 |      100 |     100 |     100 |                   
  DataProvider.ts                          |     100 |      100 |     100 |     100 |                   
  Funder.ts                                |     100 |      100 |     100 |     100 |                   
  Id.ts                                    |     100 |      100 |     100 |     100 |                   
  JsonObject.ts                            |     100 |      100 |     100 |     100 |                   
  KeycloakUserId.ts                        |   94.11 |        0 |     100 |   94.11 | 19                
  Language.ts                              |     100 |      100 |     100 |     100 |                   
  Opportunity.ts                           |     100 |      100 |     100 |     100 |                   
  PaginationParameters.ts                  |     100 |      100 |     100 |     100 |                   
  PaginationParametersQuery.ts             |     100 |      100 |     100 |     100 |                   
  PostgresErrorCode.ts                     |     100 |      100 |     100 |     100 |                   
  PresignedPostRequest.ts                  |     100 |      100 |     100 |     100 |                   
  ProcessBulkUploadJobPayload.ts           |     100 |      100 |     100 |     100 |                   
  Proposal.ts                              |     100 |      100 |     100 |     100 |                   
  ProposalFieldValue.ts                    |     100 |      100 |     100 |     100 |                   
  ProposalVersion.ts                       |     100 |      100 |     100 |     100 |                   
  ShortCode.ts                             |     100 |      100 |     100 |     100 |                   
  Source.ts                                |     100 |      100 |     100 |     100 |                   
  TableMetrics.ts                          |     100 |      100 |     100 |     100 |                   
  TinyPgErrorWithQueryContext.ts           |     100 |      100 |     100 |     100 |                   
  User.ts                                  |     100 |      100 |     100 |     100 |                   
  Uuid.ts                                  |     100 |      100 |     100 |     100 |                   
  index.ts                                 |     100 |      100 |     100 |     100 |                   
 src/types/express                         |     100 |      100 |     100 |     100 |                   
  AuthenticatedRequest.ts                  |     100 |      100 |     100 |     100 |                   
-------------------------------------------|---------|----------|---------|---------|-------------------

Test Suites: 1 passed, 1 total
Tests:       20 passed, 20 total

The expected behavior would be to omit coverage from create... methods, and really all untested code, except when it is actually under test.

slifty commented 1 month ago

I'm not sure this is actually inaccurate -- a lot of this coverage is because the code is run, even if the inner lines of, say, a given function definition is not invoked (e.g. all of the types I would expect to be considered 100% tested merely by having the modules loaded / the application started).

Are there any specific logical lines being marked as covered that you would expect to not see coverage?

bickelj commented 1 month ago

I agree that you can claim this isn't totally inaccurate: a lot of code gets run during test runs.

However there is a major qualitative difference between "code runs without blowing up" (say, coverage level 1) and "code runs and has a meaningful assertion pass that was related to that code" (say, coverage level 2). I expect "coverage" to be level 2: a meaningful assertion is involved. In other words, test setup or test harness stuff that runs before and after the code in the test body does not count as being covered merely because it ran and didn't cause an exception.

I guess there are four ways tests can "fail":

  1. Exception/error during setup
  2. Exception/error in test body
  3. Assertion failure in test body
  4. Exception/error during teardown

Some code, as you say, is executed merely because it's read, and I'm OK with that, but what I do not expect is that a test designed to cover a route that only does reads to show as "covering" the create function calls that happened during setup. Those create functions have their own tests with their own setup and teardown.

slifty commented 1 month ago

(( I wrote a thing about my understanding of the purpose of coverage reports, which is not useful any more because it was rooted in a misunderstanding of what Jesse was saying! Sorry everybody ))

slifty commented 1 month ago

Some code, as you say, is executed merely because it's read, and I'm OK with that, but what I do not expect is that a test designed to cover a route that only does reads to show as "covering" the create function calls that happened during setup. Those create functions have their own tests with their own setup and teardown.

I hear you / get your point now I think; and to repeat back my understanding:

The issue opened here could be narrowed to basically "ensure test setup and teardown logic does not count towards test coverage across our tests"

The practical benefit of this change would be that currently we risk "masking" missing tests (e.g. it is possible we never properly tested createFoo but rather we just invoked createFoo in the context of an unrelated test's setup. What we really want is for createFoo's coverage to only count if it is invoked in the context of application logic or an explicit test)


If this understanding is accurate, would you be OK with us changing the issue title to be more specific? I think that would make it more actionable as well.

bickelj commented 1 month ago

@slifty Yes, you got it. If it ain't in the test function body, it shouldn't be marked as "covered." And even if it is in the test function body, I want a way to mark it as "don't count these calls (and transitive calls from them) as covered." I should have given a couple of examples. Your summary is good though: don't count test setup and teardown toward coverage.

bickelj commented 1 month ago

To see what I was doing locally to try to reduce coverage of setup/teardown, see this branch.

bickelj commented 4 weeks ago

Taking a baseline or simpler approach, I added collectCoverage: true, to jest.config.base.js, found the smallest integration test file (users.int.test.ts), commented out all the tests save one that I added, and ran that one test with coverage.

describe('/users', () => {
    describe('GET /', () => {
        it('does not "cover" a bunch of bogus lines', async () => {
            await expect(100).toEqual(100);
        });

        /*
//...
        */
    });
});

The coverage result follows. Some of the coverage is expected and some is not. The command was node 'node_modules/jest/bin/jest.js' 'src/__tests__/users.int.test.ts' -c 'jest.config.int.js' -t '/users GET / does not "cover" a bunch of bogus lines'.

------------------------------|---------|----------|---------|---------|-------------------
File                          | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s 
------------------------------|---------|----------|---------|---------|-------------------
All files                     |   31.18 |     5.09 |   10.48 |   29.51 |                   
 src                          |   43.18 |    13.63 |   22.22 |   39.16 |                   
  ajv.ts                      |   88.88 |      100 |       0 |   88.88 | 13                
  app.ts                      |       0 |      100 |     100 |       0 | 1-31              
  config.ts                   |   72.72 |        0 |      50 |   66.66 | 12-15             
  fieldValidation.ts          |   57.89 |        0 |       0 |   58.82 | 33-45             
  index.ts                    |       0 |        0 |       0 |       0 | 1-38              
  jobQueue.ts                 |   51.51 |    28.57 |      25 |   46.42 | 14-28,33-44,55,66 
  logger.ts                   |    87.5 |       50 |      50 |      80 | 6                 
  s3Client.ts                 |     100 |      100 |     100 |     100 |                   
 src/auth                     |     100 |      100 |     100 |     100 |                   
  jwtOptions.ts               |     100 |      100 |     100 |     100 |                   
 src/database                 |     100 |        0 |     100 |     100 |                   
  db.ts                       |     100 |      100 |     100 |     100 |                   
  index.ts                    |     100 |      100 |     100 |     100 |                   
  migrate.ts                  |     100 |        0 |     100 |     100 | 9                 
 src/database/operations      |     100 |      100 |     100 |     100 |                   
  index.ts                    |     100 |      100 |     100 |     100 |                   
 ...ons/applicationFormFields |   46.42 |        0 |       0 |      44 |                   
  ...eApplicationFormField.ts |   33.33 |        0 |       0 |   33.33 | 11-27             
  index.ts                    |     100 |      100 |     100 |     100 |                   
  loadApplicationFormField.ts |   44.44 |        0 |       0 |    37.5 | 8-21              
  ...cationFormFieldBundle.ts |   42.85 |      100 |       0 |      40 | 13-23             
 ...erations/applicationForms |   46.42 |        0 |       0 |   41.66 |                   
  createApplicationForm.ts    |   33.33 |        0 |       0 |      25 | 11-24             
  index.ts                    |     100 |      100 |     100 |     100 |                   
  loadApplicationForm.ts      |   44.44 |        0 |       0 |    37.5 | 8-21              
  ...ApplicationFormBundle.ts |   42.85 |      100 |       0 |      40 | 8-17              
 ...ons/baseFieldLocalization |   47.36 |        0 |       0 |   47.05 |                   
  ...aseFieldLocalizations.ts |      40 |        0 |       0 |   33.33 | 12-32             
  index.ts                    |     100 |      100 |     100 |     100 |                   
  ...nsBundleByBaseFieldId.ts |   42.85 |      100 |       0 |      50 | 13-24             
 ...ase/operations/baseFields |   48.64 |        0 |       0 |   42.42 |                   
  createBaseField.ts          |   33.33 |        0 |       0 |      25 | 12-29             
  index.ts                    |     100 |      100 |     100 |     100 |                   
  loadBaseField.ts            |   44.44 |        0 |       0 |    37.5 | 6-19              
  loadBaseFields.ts           |      60 |      100 |       0 |      50 | 5-6               
  updateBaseField.ts          |      40 |        0 |       0 |   33.33 | 13-32             
 ...se/operations/bulkUploads |   42.85 |        0 |       0 |   37.83 |                   
  createBulkUpload.ts         |   33.33 |        0 |       0 |      25 | 11-29             
  index.ts                    |     100 |      100 |     100 |     100 |                   
  loadBulkUpload.ts           |   44.44 |        0 |       0 |    37.5 | 6-19              
  loadBulkUploadBundle.ts     |   33.33 |      100 |       0 |   28.57 | 16-31             
  updateBulkUpload.ts         |   36.36 |        0 |       0 |      30 | 13-36             
 ...ions/changemakerProposals |   44.44 |        0 |       0 |      40 |                   
  ...teChangemakerProposal.ts |   33.33 |        0 |       0 |      25 | 11-25             
  index.ts                    |     100 |      100 |     100 |     100 |                   
  ...gemakerProposalBundle.ts |   42.85 |      100 |       0 |      40 | 14-25             
 ...e/operations/changemakers |   47.61 |        0 |       0 |   43.24 |                   
  createChangemaker.ts        |   33.33 |        0 |       0 |      25 | 11-25             
  index.ts                    |     100 |      100 |     100 |     100 |                   
  loadChangemaker.ts          |   45.45 |        0 |       0 |      40 | 15-30             
  loadChangemakerBundle.ts    |   44.44 |      100 |       0 |   42.85 | 16-28             
  loadChangemakerByTaxId.ts   |   44.44 |        0 |       0 |    37.5 | 8-23              
 .../operations/dataProviders |   47.36 |        0 |       0 |   48.64 |                   
  ...eOrUpdateDataProvider.ts |   33.33 |        0 |       0 |   33.33 | 11-25             
  index.ts                    |     100 |      100 |     100 |     100 |                   
  loadDataProvider.ts         |   44.44 |        0 |       0 |   44.44 | 8-21              
  loadDataProviderBundle.ts   |   42.85 |      100 |       0 |      50 | 8-17              
  loadSystemDataProvider.ts   |   44.44 |        0 |       0 |   44.44 | 6-17              
 ...tabase/operations/funders |   46.42 |        0 |       0 |   46.15 |                   
  createOrUpdateFunder.ts     |   33.33 |        0 |       0 |   33.33 | 11-25             
  index.ts                    |     100 |      100 |     100 |     100 |                   
  loadFunder.ts               |   44.44 |        0 |       0 |    37.5 | 6-19              
  loadFunderBundle.ts         |   42.85 |      100 |       0 |      50 | 8-17              
 ...tabase/operations/generic |   52.38 |        0 |       0 |   47.36 |                   
  index.ts                    |     100 |      100 |     100 |     100 |                   
  loadBundle.ts               |   57.14 |      100 |       0 |      50 | 11-14             
  loadTableMetrics.ts         |   41.66 |        0 |       0 |   36.36 | 9-29              
 .../operations/opportunities |   46.42 |        0 |       0 |   46.15 |                   
  createOpportunity.ts        |   33.33 |        0 |       0 |      25 | 11-25             
  index.ts                    |     100 |      100 |     100 |     100 |                   
  loadOpportunity.ts          |   44.44 |        0 |       0 |   44.44 | 6-19              
  loadOpportunityBundle.ts    |   42.85 |      100 |       0 |      50 | 8-17              
 ...tions/proposalFieldValues |      40 |        0 |       0 |      40 |                   
  createProposalFieldValue.ts |   33.33 |        0 |       0 |   33.33 | 18-35             
  index.ts                    |     100 |      100 |     100 |     100 |                   
 ...erations/proposalVersions |      40 |        0 |       0 |      40 |                   
  createProposalVersion.ts    |   33.33 |        0 |       0 |   33.33 | 12-28             
  index.ts                    |     100 |      100 |     100 |     100 |                   
 ...base/operations/proposals |      45 |        0 |       0 |      40 |                   
  ...ProposalAuthorization.ts |   44.44 |        0 |       0 |    37.5 | 9-19              
  createProposal.ts           |   33.33 |        0 |       0 |      25 | 11-23             
  index.ts                    |     100 |      100 |     100 |     100 |                   
  loadProposal.ts             |   44.44 |        0 |       0 |    37.5 | 6-16              
  loadProposalBundle.ts       |   33.33 |      100 |       0 |   28.57 | 18-35             
 ...tabase/operations/sources |   46.93 |        0 |       0 |   44.44 |                   
  assertSourceExists.ts       |   57.14 |        0 |       0 |      50 | 6-11              
  createSource.ts             |      25 |        0 |       0 |   18.18 | 7-32              
  index.ts                    |     100 |      100 |     100 |     100 |                   
  loadSource.ts               |   44.44 |        0 |       0 |    37.5 | 6-16              
  loadSourceBundle.ts         |   42.85 |      100 |       0 |      50 | 8-17              
  loadSystemSource.ts         |   44.44 |        0 |       0 |   44.44 | 6-19              
 ...database/operations/users |   68.29 |    14.28 |      40 |   67.56 |                   
  createUser.ts               |   88.88 |    33.33 |     100 |    87.5 | 11                
  index.ts                    |     100 |      100 |     100 |     100 |                   
  loadSystemUser.ts           |   88.88 |        0 |     100 |   88.88 | 12                
  loadUserBundle.ts           |   33.33 |      100 |       0 |   28.57 | 16-31             
  loadUserByKeycloakUserId.ts |      50 |        0 |       0 |   44.44 | 9-22              
 src/database/parameters      |   45.45 |        0 |       0 |      40 |                   
  getLimitValues.ts           |      40 |        0 |       0 |   33.33 | 13-22             
  index.ts                    |     100 |      100 |     100 |     100 |                   
 src/errors                   |   56.66 |      100 |       0 |   56.66 |                   
  DatabaseError.ts            |      25 |      100 |       0 |      25 | 10-12             
  FailedMiddlewareError.ts    |     100 |      100 |     100 |     100 |                   
  InputConflictError.ts       |      25 |      100 |       0 |      25 | 12-14             
  InputValidationError.ts     |     100 |      100 |     100 |     100 |                   
  InternalValidationError.ts  |     100 |      100 |     100 |     100 |                   
  JobQueueStateError.ts       |       0 |      100 |     100 |       0 | 1                 
  NotFoundError.ts            |      25 |      100 |       0 |      25 | 31-33             
  UnauthorizedError.ts        |     100 |      100 |     100 |     100 |                   
  ValidationError.ts          |      25 |      100 |       0 |      25 | 9-11              
  index.ts                    |     100 |      100 |     100 |     100 |                   
 src/handlers                 |       0 |        0 |       0 |       0 |                   
  applicationFormsHandlers.ts |       0 |        0 |       0 |       0 | 1-111             
  baseFieldsHandlers.ts       |       0 |        0 |       0 |       0 | 1-220             
  bulkUploadsHandlers.ts      |       0 |        0 |       0 |       0 | 1-121             
  ...akerProposalsHandlers.ts |       0 |        0 |       0 |       0 | 1-76              
  changemakersHandlers.ts     |       0 |        0 |       0 |       0 | 1-93              
  dataProvidersHandlers.ts    |       0 |        0 |       0 |       0 | 1-112             
  fundersHandlers.ts          |       0 |        0 |       0 |       0 | 1-100             
  opportunitiesHandlers.ts    |       0 |        0 |       0 |       0 | 1-86              
  ...iderResponsesHandlers.ts |       0 |        0 |       0 |       0 | 1-125             
  ...dPostRequestsHandlers.ts |       0 |        0 |       0 |       0 | 1-56              
  proposalVersionsHandlers.ts |       0 |        0 |       0 |       0 | 1-215             
  proposalsHandlers.ts        |       0 |        0 |       0 |       0 | 1-124             
  sourcesHandlers.ts          |       0 |        0 |       0 |       0 | 1-91              
  usersHandlers.ts            |       0 |        0 |       0 |       0 | 1-36              
 src/middleware               |       0 |        0 |       0 |       0 |                   
  addRoleContext.ts           |       0 |      100 |       0 |       0 | 1-19              
  addUserContext.ts           |       0 |        0 |       0 |       0 | 1-57              
  errorHandler.ts             |       0 |        0 |       0 |       0 | 1-125             
  index.ts                    |       0 |      100 |     100 |       0 | 1-6               
  processJwt.ts               |       0 |        0 |       0 |       0 | 1-25              
  requireAdministratorRole.ts |       0 |        0 |       0 |       0 | 2-20              
  requireAuthentication.ts    |       0 |        0 |       0 |       0 | 2-30              
 src/queryParameters          |       0 |        0 |       0 |       0 |                   
  ...ChangemakerParameters.ts |       0 |        0 |       0 |       0 | 1-46              
  ...ctCreatedByParameters.ts |       0 |        0 |       0 |       0 | 1-64              
  ...cloakUserIdParameters.ts |       0 |        0 |       0 |       0 | 1-41              
  ...tPaginationParameters.ts |       0 |        0 |       0 |       0 | 1-17              
  ...actProposalParameters.ts |       0 |        0 |       0 |       0 | 1-41              
  extractSearchParameters.ts  |       0 |      100 |       0 |       0 | 3                 
  index.ts                    |       0 |      100 |     100 |       0 | 1-6               
 src/routers                  |       0 |        0 |     100 |       0 |                   
  applicationFormsRouter.ts   |       0 |      100 |     100 |       0 | 1-23              
  baseFieldsRouter.ts         |       0 |      100 |     100 |       0 | 1-28              
  bulkUploadsRouter.ts        |       0 |      100 |     100 |       0 | 1-19              
  ...emakerProposalsRouter.ts |       0 |      100 |     100 |       0 | 1-19              
  changemakersRouter.ts       |       0 |      100 |     100 |       0 | 1-17              
  dataProviderRouter.ts       |       0 |      100 |     100 |       0 | 1-25              
  documentationRouter.ts      |       0 |        0 |     100 |       0 | 1-43              
  fundersRouter.ts            |       0 |      100 |     100 |       0 | 1-21              
  index.ts                    |       0 |      100 |     100 |       0 | 1-36              
  opportunitiesRouter.ts      |       0 |      100 |     100 |       0 | 1-23              
  ...oviderResponsesRouter.ts |       0 |      100 |     100 |       0 | 1-18              
  ...nedPostRequestsRouter.ts |       0 |      100 |     100 |       0 | 1-13              
  proposalVersionsRouter.ts   |       0 |      100 |     100 |       0 | 1-13              
  proposalsRouter.ts          |       0 |      100 |     100 |       0 | 1-21              
  sourcesRouter.ts            |       0 |      100 |     100 |       0 | 1-17              
  usersRouter.ts              |       0 |      100 |     100 |       0 | 1-9               
 src/scripts                  |       0 |        0 |       0 |       0 |                   
  migrate.ts                  |       0 |        0 |       0 |       0 | 1-18              
 src/tasks                    |   17.72 |        0 |       0 |   17.19 |                   
  index.ts                    |     100 |      100 |     100 |     100 |                   
  processBulkUpload.ts        |   17.19 |        0 |       0 |   16.66 | ...01-211,218-382 
 src/test                     |   87.01 |    77.77 |   72.22 |   88.05 |                   
  harnessFunctions.ts         |   93.54 |        0 |     100 |   92.85 | 7,12              
  mockGraphileWorker.ts       |       0 |      100 |       0 |       0 | 1-5               
  mockJwt.ts                  |     100 |      100 |     100 |     100 |                   
  utils.ts                    |   81.81 |      100 |   33.33 |   81.25 | 21-22,34          
 src/types                    |   98.39 |    72.72 |   85.71 |   98.37 |                   
  ApplicationForm.ts          |     100 |      100 |     100 |     100 |                   
  ApplicationFormField.ts     |     100 |      100 |     100 |     100 |                   
  AuthContext.ts              |      80 |      100 |       0 |      80 | 36-37             
  BaseField.ts                |     100 |      100 |     100 |     100 |                   
  BaseFieldLocalization.ts    |     100 |      100 |     100 |     100 |                   
  BulkUpload.ts               |     100 |      100 |     100 |     100 |                   
  Changemaker.ts              |     100 |      100 |     100 |     100 |                   
  ChangemakerProposal.ts      |     100 |      100 |     100 |     100 |                   
  DataProvider.ts             |     100 |      100 |     100 |     100 |                   
  Funder.ts                   |     100 |      100 |     100 |     100 |                   
  Id.ts                       |     100 |      100 |     100 |     100 |                   
  JsonObject.ts               |     100 |      100 |     100 |     100 |                   
  KeycloakUserId.ts           |   94.11 |        0 |     100 |   94.11 | 19                
  Language.ts                 |     100 |      100 |     100 |     100 |                   
  Opportunity.ts              |     100 |      100 |     100 |     100 |                   
  PaginationParameters.ts     |     100 |      100 |     100 |     100 |                   
  ...nationParametersQuery.ts |     100 |      100 |     100 |     100 |                   
  PostgresErrorCode.ts        |     100 |      100 |     100 |     100 |                   
  PresignedPostRequest.ts     |     100 |      100 |     100 |     100 |                   
  ...sBulkUploadJobPayload.ts |     100 |      100 |     100 |     100 |                   
  Proposal.ts                 |     100 |      100 |     100 |     100 |                   
  ProposalFieldValue.ts       |     100 |      100 |     100 |     100 |                   
  ProposalVersion.ts          |     100 |      100 |     100 |     100 |                   
  ShortCode.ts                |     100 |      100 |     100 |     100 |                   
  Source.ts                   |     100 |      100 |     100 |     100 |                   
  TableMetrics.ts             |     100 |      100 |     100 |     100 |                   
  ...ErrorWithQueryContext.ts |     100 |      100 |     100 |     100 |                   
  User.ts                     |     100 |      100 |     100 |     100 |                   
  Uuid.ts                     |     100 |      100 |     100 |     100 |                   
  index.ts                    |     100 |      100 |     100 |     100 |                   
 src/types/express            |   73.33 |        0 |       0 |   73.33 |                   
  AuthenticatedRequest.ts     |   73.33 |        0 |       0 |   73.33 | 70,73,76-77       
------------------------------|---------|----------|---------|---------|-------------------

Test Suites: 1 passed, 1 total
Tests:       1 passed, 1 total

I do not expect migrate.ts to have 100% coverage. I'd expect migrate.ts and logger.ts to have zero coverage because they were not involved in any of this test. They were "covered" during test setup. So the next step is to try to get those two excluded.

bickelj commented 4 weeks ago

jest.config.int.js declares config.setupFilesAfterEnv = ['<rootDir>/src/test/integrationSuiteSetup.ts'];, integrationSuiteSetup.ts has a beforeEach function that calls prepareDatabaseForCurrentWorker that calls migrate in migrate.ts. So the beforeEach appears to be included in coverage. To confirm, I'll do a unit test with coverage and then add a beforeEach.

I commented out the tests in fieldValidation.unit.test.ts and added a simple assertion:


describe('field value validation against BaseFieldDataType', () => {
    test('verify beforeEach gets no coverage', () => {
        expect(200).toEqual(200);
    });

    /*
//...
    */
});

I ran node 'node_modules/jest/bin/jest.js' 'src/__tests__/fieldValidation.unit.test.ts' -c 'jest.config.unit.js' -t 'field value validation against BaseFieldDataType verify beforeEach gets no coverage' and got the following coverage. This looks more like what we'd expect.

------------------------------|---------|----------|---------|---------|-------------------
File                          | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s 
------------------------------|---------|----------|---------|---------|-------------------
All files                     |       0 |        0 |       0 |       0 |                   
 src                          |       0 |        0 |       0 |       0 |                   
  ajv.ts                      |       0 |      100 |       0 |       0 | 1-18              
  app.ts                      |       0 |      100 |     100 |       0 | 1-31              
  config.ts                   |       0 |        0 |       0 |       0 | 1-15              
  fieldValidation.ts          |       0 |        0 |       0 |       0 | 1-45              
  index.ts                    |       0 |        0 |       0 |       0 | 1-38              
  jobQueue.ts                 |       0 |        0 |       0 |       0 | 1-66              
  logger.ts                   |       0 |        0 |       0 |       0 | 1-16              
  s3Client.ts                 |       0 |      100 |     100 |       0 | 1-29              
 src/auth                     |       0 |      100 |     100 |       0 |                   
  jwtOptions.ts               |       0 |      100 |     100 |       0 | 1-12              
 src/database                 |       0 |        0 |       0 |       0 |                   
  db.ts                       |       0 |      100 |       0 |       0 | 1-25              
  index.ts                    |       0 |      100 |     100 |       0 | 1-4               
  migrate.ts                  |       0 |        0 |       0 |       0 | 1-18              
 src/database/operations      |       0 |      100 |     100 |       0 |                   
  index.ts                    |       0 |      100 |     100 |       0 | 1-16              
 ...ons/applicationFormFields |       0 |        0 |       0 |       0 |                   
  ...eApplicationFormField.ts |       0 |        0 |       0 |       0 | 1-30              
  index.ts                    |       0 |      100 |     100 |       0 | 1-3               
  loadApplicationFormField.ts |       0 |        0 |       0 |       0 | 1-21              
  ...cationFormFieldBundle.ts |       0 |      100 |       0 |       0 | 1-23              
 ...erations/applicationForms |       0 |        0 |       0 |       0 |                   
  createApplicationForm.ts    |       0 |        0 |       0 |       0 | 1-24              
  index.ts                    |       0 |      100 |     100 |       0 | 1-3               
  loadApplicationForm.ts      |       0 |        0 |       0 |       0 | 1-21              
  ...ApplicationFormBundle.ts |       0 |      100 |       0 |       0 | 1-17              
 ...ons/baseFieldLocalization |       0 |        0 |       0 |       0 |                   
  ...aseFieldLocalizations.ts |       0 |        0 |       0 |       0 | 1-32              
  index.ts                    |       0 |      100 |     100 |       0 | 1-2               
  ...nsBundleByBaseFieldId.ts |       0 |      100 |       0 |       0 | 1-30              
 ...ase/operations/baseFields |       0 |        0 |       0 |       0 |                   
  createBaseField.ts          |       0 |        0 |       0 |       0 | 1-29              
  index.ts                    |       0 |      100 |     100 |       0 | 1-4               
  loadBaseField.ts            |       0 |        0 |       0 |       0 | 1-19              
  loadBaseFields.ts           |       0 |      100 |       0 |       0 | 1-6               
  updateBaseField.ts          |       0 |        0 |       0 |       0 | 1-32              
 ...se/operations/bulkUploads |       0 |        0 |       0 |       0 |                   
  createBulkUpload.ts         |       0 |        0 |       0 |       0 | 1-29              
  index.ts                    |       0 |      100 |     100 |       0 | 1-4               
  loadBulkUpload.ts           |       0 |        0 |       0 |       0 | 1-19              
  loadBulkUploadBundle.ts     |       0 |      100 |       0 |       0 | 1-31              
  updateBulkUpload.ts         |       0 |        0 |       0 |       0 | 1-36              
 ...ions/changemakerProposals |       0 |        0 |       0 |       0 |                   
  ...teChangemakerProposal.ts |       0 |        0 |       0 |       0 | 1-25              
  index.ts                    |       0 |      100 |     100 |       0 | 1-2               
  ...gemakerProposalBundle.ts |       0 |      100 |       0 |       0 | 1-25              
 ...e/operations/changemakers |       0 |        0 |       0 |       0 |                   
  createChangemaker.ts        |       0 |        0 |       0 |       0 | 1-25              
  index.ts                    |       0 |      100 |     100 |       0 | 1-4               
  loadChangemaker.ts          |       0 |        0 |       0 |       0 | 1-30              
  loadChangemakerBundle.ts    |       0 |      100 |       0 |       0 | 1-28              
  loadChangemakerByTaxId.ts   |       0 |        0 |       0 |       0 | 1-23              
 .../operations/dataProviders |       0 |        0 |       0 |       0 |                   
  ...eOrUpdateDataProvider.ts |       0 |        0 |       0 |       0 | 1-28              
  index.ts                    |       0 |      100 |     100 |       0 | 1-4               
  loadDataProvider.ts         |       0 |        0 |       0 |       0 | 1-24              
  loadDataProviderBundle.ts   |       0 |      100 |       0 |       0 | 1-23              
  loadSystemDataProvider.ts   |       0 |        0 |       0 |       0 | 1-20              
 ...tabase/operations/funders |       0 |        0 |       0 |       0 |                   
  createOrUpdateFunder.ts     |       0 |        0 |       0 |       0 | 1-28              
  index.ts                    |       0 |      100 |     100 |       0 | 1-3               
  loadFunder.ts               |       0 |        0 |       0 |       0 | 1-19              
  loadFunderBundle.ts         |       0 |      100 |       0 |       0 | 1-23              
 ...tabase/operations/generic |       0 |        0 |       0 |       0 |                   
  index.ts                    |       0 |      100 |     100 |       0 | 1-2               
  loadBundle.ts               |       0 |      100 |       0 |       0 | 1-14              
  loadTableMetrics.ts         |       0 |        0 |       0 |       0 | 1-29              
 .../operations/opportunities |       0 |        0 |       0 |       0 |                   
  createOpportunity.ts        |       0 |        0 |       0 |       0 | 1-25              
  index.ts                    |       0 |      100 |     100 |       0 | 1-3               
  loadOpportunity.ts          |       0 |        0 |       0 |       0 | 1-22              
  loadOpportunityBundle.ts    |       0 |      100 |       0 |       0 | 1-23              
 ...tions/proposalFieldValues |       0 |        0 |       0 |       0 |                   
  createProposalFieldValue.ts |       0 |        0 |       0 |       0 | 1-38              
  index.ts                    |       0 |      100 |     100 |       0 | 1                 
 ...erations/proposalVersions |       0 |        0 |       0 |       0 |                   
  createProposalVersion.ts    |       0 |        0 |       0 |       0 | 1-31              
  index.ts                    |       0 |      100 |     100 |       0 | 1                 
 ...base/operations/proposals |       0 |        0 |       0 |       0 |                   
  ...ProposalAuthorization.ts |       0 |        0 |       0 |       0 | 1-19              
  createProposal.ts           |       0 |        0 |       0 |       0 | 1-23              
  index.ts                    |       0 |      100 |     100 |       0 | 1-4               
  loadProposal.ts             |       0 |        0 |       0 |       0 | 1-16              
  loadProposalBundle.ts       |       0 |      100 |       0 |       0 | 1-35              
 ...tabase/operations/sources |       0 |        0 |       0 |       0 |                   
  assertSourceExists.ts       |       0 |        0 |       0 |       0 | 1-11              
  createSource.ts             |       0 |        0 |       0 |       0 | 1-32              
  index.ts                    |       0 |      100 |     100 |       0 | 1-5               
  loadSource.ts               |       0 |        0 |       0 |       0 | 1-16              
  loadSourceBundle.ts         |       0 |      100 |       0 |       0 | 1-23              
  loadSystemSource.ts         |       0 |        0 |       0 |       0 | 1-22              
 ...database/operations/users |       0 |        0 |       0 |       0 |                   
  createUser.ts               |       0 |        0 |       0 |       0 | 1-15              
  index.ts                    |       0 |      100 |     100 |       0 | 1-4               
  loadSystemUser.ts           |       0 |        0 |       0 |       0 | 1-22              
  loadUserBundle.ts           |       0 |      100 |       0 |       0 | 1-31              
  loadUserByKeycloakUserId.ts |       0 |        0 |       0 |       0 | 1-22              
 src/database/parameters      |       0 |        0 |       0 |       0 |                   
  getLimitValues.ts           |       0 |        0 |       0 |       0 | 1-22              
  index.ts                    |       0 |      100 |     100 |       0 | 1                 
 src/errors                   |       0 |      100 |       0 |       0 |                   
  DatabaseError.ts            |       0 |      100 |       0 |       0 | 3-12              
  FailedMiddlewareError.ts    |       0 |      100 |     100 |       0 | 3                 
  InputConflictError.ts       |       0 |      100 |       0 |       0 | 8-14              
  InputValidationError.ts     |       0 |      100 |     100 |       0 | 1-3               
  InternalValidationError.ts  |       0 |      100 |     100 |       0 | 1-3               
  JobQueueStateError.ts       |       0 |      100 |     100 |       0 | 1                 
  NotFoundError.ts            |       0 |      100 |       0 |       0 | 27-33             
  UnauthorizedError.ts        |       0 |      100 |     100 |       0 | 1                 
  ValidationError.ts          |       0 |      100 |       0 |       0 | 5-11              
  index.ts                    |       0 |      100 |     100 |       0 | 1-7               
 src/handlers                 |       0 |        0 |       0 |       0 |                   
  applicationFormsHandlers.ts |       0 |        0 |       0 |       0 | 1-111             
  baseFieldsHandlers.ts       |       0 |        0 |       0 |       0 | 1-220             
  bulkUploadsHandlers.ts      |       0 |        0 |       0 |       0 | 1-121             
  ...akerProposalsHandlers.ts |       0 |        0 |       0 |       0 | 1-76              
  changemakersHandlers.ts     |       0 |        0 |       0 |       0 | 1-93              
  dataProvidersHandlers.ts    |       0 |        0 |       0 |       0 | 1-112             
  fundersHandlers.ts          |       0 |        0 |       0 |       0 | 1-100             
  opportunitiesHandlers.ts    |       0 |        0 |       0 |       0 | 1-86              
  ...iderResponsesHandlers.ts |       0 |        0 |       0 |       0 | 1-125             
  ...dPostRequestsHandlers.ts |       0 |        0 |       0 |       0 | 1-56              
  proposalVersionsHandlers.ts |       0 |        0 |       0 |       0 | 1-215             
  proposalsHandlers.ts        |       0 |        0 |       0 |       0 | 1-124             
  sourcesHandlers.ts          |       0 |        0 |       0 |       0 | 1-91              
  usersHandlers.ts            |       0 |        0 |       0 |       0 | 1-36              
 src/middleware               |       0 |        0 |       0 |       0 |                   
  addRoleContext.ts           |       0 |      100 |       0 |       0 | 1-19              
  addUserContext.ts           |       0 |        0 |       0 |       0 | 1-57              
  errorHandler.ts             |       0 |        0 |       0 |       0 | 1-125             
  index.ts                    |       0 |      100 |     100 |       0 | 1-6               
  processJwt.ts               |       0 |        0 |       0 |       0 | 1-25              
  requireAdministratorRole.ts |       0 |        0 |       0 |       0 | 2-20              
  requireAuthentication.ts    |       0 |        0 |       0 |       0 | 2-30              
 src/queryParameters          |       0 |        0 |       0 |       0 |                   
  ...ChangemakerParameters.ts |       0 |        0 |       0 |       0 | 1-46              
  ...ctCreatedByParameters.ts |       0 |        0 |       0 |       0 | 1-64              
  ...cloakUserIdParameters.ts |       0 |        0 |       0 |       0 | 1-41              
  ...tPaginationParameters.ts |       0 |        0 |       0 |       0 | 1-17              
  ...actProposalParameters.ts |       0 |        0 |       0 |       0 | 1-41              
  extractSearchParameters.ts  |       0 |      100 |       0 |       0 | 3                 
  index.ts                    |       0 |      100 |     100 |       0 | 1-6               
 src/routers                  |       0 |        0 |     100 |       0 |                   
  applicationFormsRouter.ts   |       0 |      100 |     100 |       0 | 1-23              
  baseFieldsRouter.ts         |       0 |      100 |     100 |       0 | 1-28              
  bulkUploadsRouter.ts        |       0 |      100 |     100 |       0 | 1-19              
  ...emakerProposalsRouter.ts |       0 |      100 |     100 |       0 | 1-19              
  changemakersRouter.ts       |       0 |      100 |     100 |       0 | 1-17              
  dataProviderRouter.ts       |       0 |      100 |     100 |       0 | 1-25              
  documentationRouter.ts      |       0 |        0 |     100 |       0 | 1-43              
  fundersRouter.ts            |       0 |      100 |     100 |       0 | 1-21              
  index.ts                    |       0 |      100 |     100 |       0 | 1-36              
  opportunitiesRouter.ts      |       0 |      100 |     100 |       0 | 1-23              
  ...oviderResponsesRouter.ts |       0 |      100 |     100 |       0 | 1-18              
  ...nedPostRequestsRouter.ts |       0 |      100 |     100 |       0 | 1-13              
  proposalVersionsRouter.ts   |       0 |      100 |     100 |       0 | 1-13              
  proposalsRouter.ts          |       0 |      100 |     100 |       0 | 1-21              
  sourcesRouter.ts            |       0 |      100 |     100 |       0 | 1-17              
  usersRouter.ts              |       0 |      100 |     100 |       0 | 1-9               
 src/scripts                  |       0 |        0 |       0 |       0 |                   
  migrate.ts                  |       0 |        0 |       0 |       0 | 1-18              
 src/tasks                    |       0 |        0 |       0 |       0 |                   
  index.ts                    |       0 |      100 |     100 |       0 | 1                 
  processBulkUpload.ts        |       0 |        0 |       0 |       0 | 1-382             
 src/test                     |       0 |        0 |       0 |       0 |                   
  harnessFunctions.ts         |       0 |        0 |       0 |       0 | 1-52              
  integrationSuiteSetup.ts    |       0 |      100 |       0 |       0 | 1-41              
  mockGraphileWorker.ts       |       0 |      100 |       0 |       0 | 1-5               
  mockJwt.ts                  |       0 |        0 |       0 |       0 | 1-55              
  utils.ts                    |       0 |      100 |       0 |       0 | 1-38              
 src/types                    |       0 |        0 |       0 |       0 |                   
  ApplicationForm.ts          |       0 |      100 |     100 |       0 | 1-46              
  ApplicationFormField.ts     |       0 |      100 |     100 |       0 | 23-43             
  AuthContext.ts              |       0 |      100 |       0 |       0 | 1-44              
  BaseField.ts                |       0 |        0 |       0 |       0 | 1-63              
  BaseFieldLocalization.ts    |       0 |      100 |     100 |       0 | 1-61              
  BulkUpload.ts               |       0 |        0 |       0 |       0 | 1-58              
  Changemaker.ts              |       0 |      100 |     100 |       0 | 1-35              
  ChangemakerProposal.ts      |       0 |      100 |     100 |       0 | 1-36              
  DataProvider.ts             |       0 |      100 |     100 |       0 | 1-32              
  Funder.ts                   |       0 |      100 |     100 |       0 | 1-28              
  Id.ts                       |       0 |      100 |     100 |       0 | 1-12              
  JsonObject.ts               |       0 |      100 |     100 |       0 | 1-10              
  KeycloakUserId.ts           |       0 |        0 |       0 |       0 | 1-35              
  Language.ts                 |       0 |      100 |     100 |       0 | 1-11              
  Opportunity.ts              |       0 |      100 |     100 |       0 | 1-28              
  PaginationParameters.ts     |       0 |      100 |     100 |       0 | 1-25              
  ...nationParametersQuery.ts |       0 |      100 |     100 |       0 | 1-27              
  PostgresErrorCode.ts        |       0 |        0 |       0 |       0 | 2-5               
  PresignedPostRequest.ts     |       0 |      100 |     100 |       0 | 1-66              
  ...sBulkUploadJobPayload.ts |       0 |      100 |     100 |       0 | 1-19              
  Proposal.ts                 |       0 |      100 |     100 |       0 | 1-42              
  ProposalFieldValue.ts       |       0 |      100 |     100 |       0 | 24-47             
  ProposalVersion.ts          |       0 |      100 |     100 |       0 | 1-62              
  ShortCode.ts                |       0 |      100 |     100 |       0 | 1-13              
  Source.ts                   |       0 |      100 |     100 |       0 | 1-75              
  TableMetrics.ts             |       0 |      100 |     100 |       0 | 1-24              
  ...ErrorWithQueryContext.ts |       0 |      100 |     100 |       0 | 1-45              
  User.ts                     |       0 |      100 |     100 |       0 | 1-24              
  Uuid.ts                     |       0 |      100 |     100 |       0 | 1-15              
  index.ts                    |       0 |      100 |     100 |       0 | 1-34              
 src/types/express            |       0 |        0 |       0 |       0 |                   
  AuthenticatedRequest.ts     |       0 |        0 |       0 |       0 | 2-84              
------------------------------|---------|----------|---------|---------|-------------------

Test Suites: 1 passed, 1 total
Tests:       1 passed, 1 total

I added a beforeEach that gets a logger and logs a statement using that logger. Sure enough, beforeEach seems to be included in coverage, with non-zero coverage for logger.ts.


describe('field value validation against BaseFieldDataType', () => {
    beforeEach(() => {
        const logger = getLogger('blah');
        logger.info('This is in a beforeEach');
    });

    test('verify beforeEach gets no coverage', () => {
        expect(200).toEqual(200);
    });

    /*
//...
    */
});

Coverage result follows, specifically note the logger.ts non-zero coverage.

------------------------------|---------|----------|---------|---------|-------------------
File                          | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s 
------------------------------|---------|----------|---------|---------|-------------------
All files                     |    0.33 |     0.26 |    0.34 |    0.19 |                   
 src                          |     5.3 |     4.54 |    5.55 |    3.33 |                   
  ajv.ts                      |       0 |      100 |       0 |       0 | 1-18              
  app.ts                      |       0 |      100 |     100 |       0 | 1-31              
  config.ts                   |       0 |        0 |       0 |       0 | 1-15              
  fieldValidation.ts          |       0 |        0 |       0 |       0 | 1-45              
  index.ts                    |       0 |        0 |       0 |       0 | 1-38              
  jobQueue.ts                 |       0 |        0 |       0 |       0 | 1-66              
  logger.ts                   |    87.5 |       50 |      50 |      80 | 6                 
  s3Client.ts                 |       0 |      100 |     100 |       0 | 1-29              
 src/auth                     |       0 |      100 |     100 |       0 |                   
  jwtOptions.ts               |       0 |      100 |     100 |       0 | 1-12              
 src/database                 |       0 |        0 |       0 |       0 |                   
  db.ts                       |       0 |      100 |       0 |       0 | 1-25              
  index.ts                    |       0 |      100 |     100 |       0 | 1-4               
  migrate.ts                  |       0 |        0 |       0 |       0 | 1-18              
 src/database/operations      |       0 |      100 |     100 |       0 |                   
  index.ts                    |       0 |      100 |     100 |       0 | 1-16              
 ...ons/applicationFormFields |       0 |        0 |       0 |       0 |                   
  ...eApplicationFormField.ts |       0 |        0 |       0 |       0 | 1-30              
  index.ts                    |       0 |      100 |     100 |       0 | 1-3               
  loadApplicationFormField.ts |       0 |        0 |       0 |       0 | 1-21              
  ...cationFormFieldBundle.ts |       0 |      100 |       0 |       0 | 1-23              
 ...erations/applicationForms |       0 |        0 |       0 |       0 |                   
  createApplicationForm.ts    |       0 |        0 |       0 |       0 | 1-24              
  index.ts                    |       0 |      100 |     100 |       0 | 1-3               
  loadApplicationForm.ts      |       0 |        0 |       0 |       0 | 1-21              
  ...ApplicationFormBundle.ts |       0 |      100 |       0 |       0 | 1-17              
 ...ons/baseFieldLocalization |       0 |        0 |       0 |       0 |                   
  ...aseFieldLocalizations.ts |       0 |        0 |       0 |       0 | 1-32              
  index.ts                    |       0 |      100 |     100 |       0 | 1-2               
  ...nsBundleByBaseFieldId.ts |       0 |      100 |       0 |       0 | 1-30              
 ...ase/operations/baseFields |       0 |        0 |       0 |       0 |                   
  createBaseField.ts          |       0 |        0 |       0 |       0 | 1-29              
  index.ts                    |       0 |      100 |     100 |       0 | 1-4               
  loadBaseField.ts            |       0 |        0 |       0 |       0 | 1-19              
  loadBaseFields.ts           |       0 |      100 |       0 |       0 | 1-6               
  updateBaseField.ts          |       0 |        0 |       0 |       0 | 1-32              
 ...se/operations/bulkUploads |       0 |        0 |       0 |       0 |                   
  createBulkUpload.ts         |       0 |        0 |       0 |       0 | 1-29              
  index.ts                    |       0 |      100 |     100 |       0 | 1-4               
  loadBulkUpload.ts           |       0 |        0 |       0 |       0 | 1-19              
  loadBulkUploadBundle.ts     |       0 |      100 |       0 |       0 | 1-31              
  updateBulkUpload.ts         |       0 |        0 |       0 |       0 | 1-36              
 ...ions/changemakerProposals |       0 |        0 |       0 |       0 |                   
  ...teChangemakerProposal.ts |       0 |        0 |       0 |       0 | 1-25              
  index.ts                    |       0 |      100 |     100 |       0 | 1-2               
  ...gemakerProposalBundle.ts |       0 |      100 |       0 |       0 | 1-25              
 ...e/operations/changemakers |       0 |        0 |       0 |       0 |                   
  createChangemaker.ts        |       0 |        0 |       0 |       0 | 1-25              
  index.ts                    |       0 |      100 |     100 |       0 | 1-4               
  loadChangemaker.ts          |       0 |        0 |       0 |       0 | 1-30              
  loadChangemakerBundle.ts    |       0 |      100 |       0 |       0 | 1-28              
  loadChangemakerByTaxId.ts   |       0 |        0 |       0 |       0 | 1-23              
 .../operations/dataProviders |       0 |        0 |       0 |       0 |                   
  ...eOrUpdateDataProvider.ts |       0 |        0 |       0 |       0 | 1-28              
  index.ts                    |       0 |      100 |     100 |       0 | 1-4               
  loadDataProvider.ts         |       0 |        0 |       0 |       0 | 1-24              
  loadDataProviderBundle.ts   |       0 |      100 |       0 |       0 | 1-23              
  loadSystemDataProvider.ts   |       0 |        0 |       0 |       0 | 1-20              
 ...tabase/operations/funders |       0 |        0 |       0 |       0 |                   
  createOrUpdateFunder.ts     |       0 |        0 |       0 |       0 | 1-28              
  index.ts                    |       0 |      100 |     100 |       0 | 1-3               
  loadFunder.ts               |       0 |        0 |       0 |       0 | 1-19              
  loadFunderBundle.ts         |       0 |      100 |       0 |       0 | 1-23              
 ...tabase/operations/generic |       0 |        0 |       0 |       0 |                   
  index.ts                    |       0 |      100 |     100 |       0 | 1-2               
  loadBundle.ts               |       0 |      100 |       0 |       0 | 1-14              
  loadTableMetrics.ts         |       0 |        0 |       0 |       0 | 1-29              
 .../operations/opportunities |       0 |        0 |       0 |       0 |                   
  createOpportunity.ts        |       0 |        0 |       0 |       0 | 1-25              
  index.ts                    |       0 |      100 |     100 |       0 | 1-3               
  loadOpportunity.ts          |       0 |        0 |       0 |       0 | 1-22              
  loadOpportunityBundle.ts    |       0 |      100 |       0 |       0 | 1-23              
 ...tions/proposalFieldValues |       0 |        0 |       0 |       0 |                   
  createProposalFieldValue.ts |       0 |        0 |       0 |       0 | 1-38              
  index.ts                    |       0 |      100 |     100 |       0 | 1                 
 ...erations/proposalVersions |       0 |        0 |       0 |       0 |                   
  createProposalVersion.ts    |       0 |        0 |       0 |       0 | 1-31              
  index.ts                    |       0 |      100 |     100 |       0 | 1                 
 ...base/operations/proposals |       0 |        0 |       0 |       0 |                   
  ...ProposalAuthorization.ts |       0 |        0 |       0 |       0 | 1-19              
  createProposal.ts           |       0 |        0 |       0 |       0 | 1-23              
  index.ts                    |       0 |      100 |     100 |       0 | 1-4               
  loadProposal.ts             |       0 |        0 |       0 |       0 | 1-16              
  loadProposalBundle.ts       |       0 |      100 |       0 |       0 | 1-35              
 ...tabase/operations/sources |       0 |        0 |       0 |       0 |                   
  assertSourceExists.ts       |       0 |        0 |       0 |       0 | 1-11              
  createSource.ts             |       0 |        0 |       0 |       0 | 1-32              
  index.ts                    |       0 |      100 |     100 |       0 | 1-5               
  loadSource.ts               |       0 |        0 |       0 |       0 | 1-16              
  loadSourceBundle.ts         |       0 |      100 |       0 |       0 | 1-23              
  loadSystemSource.ts         |       0 |        0 |       0 |       0 | 1-22              
 ...database/operations/users |       0 |        0 |       0 |       0 |                   
  createUser.ts               |       0 |        0 |       0 |       0 | 1-15              
  index.ts                    |       0 |      100 |     100 |       0 | 1-4               
  loadSystemUser.ts           |       0 |        0 |       0 |       0 | 1-22              
  loadUserBundle.ts           |       0 |      100 |       0 |       0 | 1-31              
  loadUserByKeycloakUserId.ts |       0 |        0 |       0 |       0 | 1-22              
 src/database/parameters      |       0 |        0 |       0 |       0 |                   
  getLimitValues.ts           |       0 |        0 |       0 |       0 | 1-22              
  index.ts                    |       0 |      100 |     100 |       0 | 1                 
 src/errors                   |       0 |      100 |       0 |       0 |                   
  DatabaseError.ts            |       0 |      100 |       0 |       0 | 3-12              
  FailedMiddlewareError.ts    |       0 |      100 |     100 |       0 | 3                 
  InputConflictError.ts       |       0 |      100 |       0 |       0 | 8-14              
  InputValidationError.ts     |       0 |      100 |     100 |       0 | 1-3               
  InternalValidationError.ts  |       0 |      100 |     100 |       0 | 1-3               
  JobQueueStateError.ts       |       0 |      100 |     100 |       0 | 1                 
  NotFoundError.ts            |       0 |      100 |       0 |       0 | 27-33             
  UnauthorizedError.ts        |       0 |      100 |     100 |       0 | 1                 
  ValidationError.ts          |       0 |      100 |       0 |       0 | 5-11              
  index.ts                    |       0 |      100 |     100 |       0 | 1-7               
 src/handlers                 |       0 |        0 |       0 |       0 |                   
  applicationFormsHandlers.ts |       0 |        0 |       0 |       0 | 1-111             
  baseFieldsHandlers.ts       |       0 |        0 |       0 |       0 | 1-220             
  bulkUploadsHandlers.ts      |       0 |        0 |       0 |       0 | 1-121             
  ...akerProposalsHandlers.ts |       0 |        0 |       0 |       0 | 1-76              
  changemakersHandlers.ts     |       0 |        0 |       0 |       0 | 1-93              
  dataProvidersHandlers.ts    |       0 |        0 |       0 |       0 | 1-112             
  fundersHandlers.ts          |       0 |        0 |       0 |       0 | 1-100             
  opportunitiesHandlers.ts    |       0 |        0 |       0 |       0 | 1-86              
  ...iderResponsesHandlers.ts |       0 |        0 |       0 |       0 | 1-125             
  ...dPostRequestsHandlers.ts |       0 |        0 |       0 |       0 | 1-56              
  proposalVersionsHandlers.ts |       0 |        0 |       0 |       0 | 1-215             
  proposalsHandlers.ts        |       0 |        0 |       0 |       0 | 1-124             
  sourcesHandlers.ts          |       0 |        0 |       0 |       0 | 1-91              
  usersHandlers.ts            |       0 |        0 |       0 |       0 | 1-36              
 src/middleware               |       0 |        0 |       0 |       0 |                   
  addRoleContext.ts           |       0 |      100 |       0 |       0 | 1-19              
  addUserContext.ts           |       0 |        0 |       0 |       0 | 1-57              
  errorHandler.ts             |       0 |        0 |       0 |       0 | 1-125             
  index.ts                    |       0 |      100 |     100 |       0 | 1-6               
  processJwt.ts               |       0 |        0 |       0 |       0 | 1-25              
  requireAdministratorRole.ts |       0 |        0 |       0 |       0 | 2-20              
  requireAuthentication.ts    |       0 |        0 |       0 |       0 | 2-30              
 src/queryParameters          |       0 |        0 |       0 |       0 |                   
  ...ChangemakerParameters.ts |       0 |        0 |       0 |       0 | 1-46              
  ...ctCreatedByParameters.ts |       0 |        0 |       0 |       0 | 1-64              
  ...cloakUserIdParameters.ts |       0 |        0 |       0 |       0 | 1-41              
  ...tPaginationParameters.ts |       0 |        0 |       0 |       0 | 1-17              
  ...actProposalParameters.ts |       0 |        0 |       0 |       0 | 1-41              
  extractSearchParameters.ts  |       0 |      100 |       0 |       0 | 3                 
  index.ts                    |       0 |      100 |     100 |       0 | 1-6               
 src/routers                  |       0 |        0 |     100 |       0 |                   
  applicationFormsRouter.ts   |       0 |      100 |     100 |       0 | 1-23              
  baseFieldsRouter.ts         |       0 |      100 |     100 |       0 | 1-28              
  bulkUploadsRouter.ts        |       0 |      100 |     100 |       0 | 1-19              
  ...emakerProposalsRouter.ts |       0 |      100 |     100 |       0 | 1-19              
  changemakersRouter.ts       |       0 |      100 |     100 |       0 | 1-17              
  dataProviderRouter.ts       |       0 |      100 |     100 |       0 | 1-25              
  documentationRouter.ts      |       0 |        0 |     100 |       0 | 1-43              
  fundersRouter.ts            |       0 |      100 |     100 |       0 | 1-21              
  index.ts                    |       0 |      100 |     100 |       0 | 1-36              
  opportunitiesRouter.ts      |       0 |      100 |     100 |       0 | 1-23              
  ...oviderResponsesRouter.ts |       0 |      100 |     100 |       0 | 1-18              
  ...nedPostRequestsRouter.ts |       0 |      100 |     100 |       0 | 1-13              
  proposalVersionsRouter.ts   |       0 |      100 |     100 |       0 | 1-13              
  proposalsRouter.ts          |       0 |      100 |     100 |       0 | 1-21              
  sourcesRouter.ts            |       0 |      100 |     100 |       0 | 1-17              
  usersRouter.ts              |       0 |      100 |     100 |       0 | 1-9               
 src/scripts                  |       0 |        0 |       0 |       0 |                   
  migrate.ts                  |       0 |        0 |       0 |       0 | 1-18              
 src/tasks                    |       0 |        0 |       0 |       0 |                   
  index.ts                    |       0 |      100 |     100 |       0 | 1                 
  processBulkUpload.ts        |       0 |        0 |       0 |       0 | 1-382             
 src/test                     |       0 |        0 |       0 |       0 |                   
  harnessFunctions.ts         |       0 |        0 |       0 |       0 | 1-52              
  integrationSuiteSetup.ts    |       0 |      100 |       0 |       0 | 1-41              
  mockGraphileWorker.ts       |       0 |      100 |       0 |       0 | 1-5               
  mockJwt.ts                  |       0 |        0 |       0 |       0 | 1-55              
  utils.ts                    |       0 |      100 |       0 |       0 | 1-38              
 src/types                    |       0 |        0 |       0 |       0 |                   
  ApplicationForm.ts          |       0 |      100 |     100 |       0 | 1-46              
  ApplicationFormField.ts     |       0 |      100 |     100 |       0 | 23-43             
  AuthContext.ts              |       0 |      100 |       0 |       0 | 1-44              
  BaseField.ts                |       0 |        0 |       0 |       0 | 1-63              
  BaseFieldLocalization.ts    |       0 |      100 |     100 |       0 | 1-61              
  BulkUpload.ts               |       0 |        0 |       0 |       0 | 1-58              
  Changemaker.ts              |       0 |      100 |     100 |       0 | 1-35              
  ChangemakerProposal.ts      |       0 |      100 |     100 |       0 | 1-36              
  DataProvider.ts             |       0 |      100 |     100 |       0 | 1-32              
  Funder.ts                   |       0 |      100 |     100 |       0 | 1-28              
  Id.ts                       |       0 |      100 |     100 |       0 | 1-12              
  JsonObject.ts               |       0 |      100 |     100 |       0 | 1-10              
  KeycloakUserId.ts           |       0 |        0 |       0 |       0 | 1-35              
  Language.ts                 |       0 |      100 |     100 |       0 | 1-11              
  Opportunity.ts              |       0 |      100 |     100 |       0 | 1-28              
  PaginationParameters.ts     |       0 |      100 |     100 |       0 | 1-25              
  ...nationParametersQuery.ts |       0 |      100 |     100 |       0 | 1-27              
  PostgresErrorCode.ts        |       0 |        0 |       0 |       0 | 2-5               
  PresignedPostRequest.ts     |       0 |      100 |     100 |       0 | 1-66              
  ...sBulkUploadJobPayload.ts |       0 |      100 |     100 |       0 | 1-19              
  Proposal.ts                 |       0 |      100 |     100 |       0 | 1-42              
  ProposalFieldValue.ts       |       0 |      100 |     100 |       0 | 24-47             
  ProposalVersion.ts          |       0 |      100 |     100 |       0 | 1-62              
  ShortCode.ts                |       0 |      100 |     100 |       0 | 1-13              
  Source.ts                   |       0 |      100 |     100 |       0 | 1-75              
  TableMetrics.ts             |       0 |      100 |     100 |       0 | 1-24              
  ...ErrorWithQueryContext.ts |       0 |      100 |     100 |       0 | 1-45              
  User.ts                     |       0 |      100 |     100 |       0 | 1-24              
  Uuid.ts                     |       0 |      100 |     100 |       0 | 1-15              
  index.ts                    |       0 |      100 |     100 |       0 | 1-34              
 src/types/express            |       0 |        0 |       0 |       0 |                   
  AuthenticatedRequest.ts     |       0 |        0 |       0 |       0 | 2-84              
------------------------------|---------|----------|---------|---------|-------------------

Test Suites: 1 passed, 1 total
Tests:       1 passed, 1 total

The value of checking this is that none of our integration test setup was involved, this confirms that something about our jest setup regardless of integration test configuration is improperly including beforeEach because the issue occurred with a simple unit test.

bickelj commented 4 weeks ago

I searched for "coverage" in the jest docs, but could not find anything about "beforeEach" or "beforeAll" contributing to coverage. Likewise, an issue search reveals no issues with a title resembling this problem.

bickelj commented 4 weeks ago

Maybe the next step is to make a compact JS project that reproduces the issue and file an issue with jest.