When I generate a coverage report with Jest for my Typescript project, the import statements at the top of each Typescript file do not count toward the total number of statements in the file.
I'm in the process of setting up a second coverage report for backend code that is exercised by Cypress tests, and have successfully instrumented code using their @cypress/code-coverage module. However, the reports that I get count import statements.
The line that starts up the backend code (source) is:
nyc --silent ts-node --swc scripts/serve_dev.ts
For example, in Jest, the file below has 4 statements. In Cypress, it has 10, because the 5 imports and the final export are counted.
I know this issue involves a number of other libraries besides nyc, so this may not be the right place to ask the question, but I'm hoping there's a way to configure nyc so that the two behaviors match.
import type { VercelRequest, VercelResponse } from '@vercel/node';
import { authCircleAdminMiddleware } from '../../../../api-lib/circleAdmin';
import { ENTRANCE } from '../../../../src/common-lib/constants';
import {
createUserSchemaInput,
composeHasuraActionRequestBody,
} from '../../../../src/lib/zod';
import { createUserMutation } from './createUserMutation';
async function handler(req: VercelRequest, res: VercelResponse) {
const {
input: { payload: input },
} = composeHasuraActionRequestBody(createUserSchemaInput).parse(req.body);
// External Constraint Validation
// It might be preferable to add this uniqueness constraint into the database
const { circle_id, address } = input;
const mutationResult = await createUserMutation(
address,
circle_id,
input,
ENTRANCE.LINK
);
return res
.status(200)
.json(mutationResult.insert_users_one ?? mutationResult.update_users_by_pk);
}
export default authCircleAdminMiddleware(handler);
When I generate a coverage report with Jest for my Typescript project, the
import
statements at the top of each Typescript file do not count toward the total number of statements in the file.I'm in the process of setting up a second coverage report for backend code that is exercised by Cypress tests, and have successfully instrumented code using their
@cypress/code-coverage
module. However, the reports that I get countimport
statements.The line that starts up the backend code (source) is:
For example, in Jest, the file below has 4 statements. In Cypress, it has 10, because the 5 imports and the final export are counted.
I know this issue involves a number of other libraries besides nyc, so this may not be the right place to ask the question, but I'm hoping there's a way to configure nyc so that the two behaviors match.