Open bickelj opened 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?
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":
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 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 ))
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.
@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.
To see what I was doing locally to try to reduce coverage of setup/teardown, see this branch.
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.
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.
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.
Maybe the next step is to make a compact JS project that reproduces the issue and file an issue with jest
.
During #1262, while working in the
/changemakers
integration tests, I figured thatbeforeEach
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:The expected behavior would be to omit coverage from
create...
methods, and really all untested code, except when it is actually under test.