[Bug]: Jest showing wrong coverage report
Version
29.7.0
Steps to reproduce
Jest dependencies:
"jest-environment-jsdom": "^29.7.0",
"@jest/types": "^29.6.3",
"@testing-library/jest-dom": "^6.4.2",
"@types/jest": "^29.5.12",
"jest": "^29.7.0",
"ts-jest": "^29.2.3",
Jest config:
import type {Config} from '@jest/types';
const baseConfig: Config.InitialOptions = {
rootDir: '../../',
preset: 'ts-jest',
reporters: ['default'],
clearMocks: true,
testEnvironment: 'jest-environment-jsdom',
transform: {
'^.+\\.(ts|tsx)$': 'ts-jest',
},
moduleNameMapper: {
'styled-components/macro': '<rootDir>/node_modules/styled-components',
},
};
export default baseConfig;
Expected behavior
All lines coverage.
Actual behavior
Display wrong coverage since no lines are remaining to cover.
b7e0)
Additional context
No response
Environment
System:
OS: macOS 14.5
CPU: (10) arm64 Apple M1 Max
Binaries:
Node: 20.15.1 - ~/.nvm/versions/node/v20.15.1/bin/node
Yarn: 1.22.22 - ~/.yarn/bin/yarn
npm: 10.8.2 - ~/.nvm/versions/node/v20.15.1/bin/npm
npmPackages:
jest: ^29.7.0 => 29.7.0
Facing the same issue.
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 30 days.
This still happening
I'm experiencing the same error with 29.7.0.
hey @lucaslacerdacl I am not able to reproduce this My test file is:
import { InputType } from '../enums/input-type';
import { getFormattedValue } from './input-mask';
describe('input-mask', () => {
it('should mask phone number', () => {
expect(getFormattedValue('1234567890', InputType.phone)).toBe(
'(123) 456-7890',
);
});
it('should mask zip code', () => {
expect(getFormattedValue('1234567890', InputType.zip)).toBe('12345-6789');
});
it('should return the original value', () => {
expect(getFormattedValue('1234567890', 'unknown' as any)).toBe(
'1234567890',
);
});
it('should return the original value if the value is empty', () => {
expect(getFormattedValue('', InputType.phone)).toBe('');
});
it('should format complete Canadian postal code with hyphen', () => {
expect(getFormattedValue('M5V3L9', InputType.zip)).toBe('M5V-3L9');
expect(getFormattedValue('m5v3l9', InputType.zip)).toBe('M5V-3L9');
});
it('should format partial Canadian postal code without hyphen', () => {
expect(getFormattedValue('M5V', InputType.zip)).toBe('M5V');
expect(getFormattedValue('m5v', InputType.zip)).toBe('M5V');
});
it('should remove non-alphanumeric characters', () => {
expect(getFormattedValue('M5V 3L9', InputType.zip)).toBe('M5V-3L9');
expect(getFormattedValue('M5V-3L9', InputType.zip)).toBe('M5V-3L9');
expect(getFormattedValue('M#5V@3L9', InputType.zip)).toBe('M5V-3L9');
});
it('should return just the first five digits when only those are provided', () => {
expect(getFormattedValue('12345', InputType.zip)).toBe('12345');
expect(getFormattedValue('12345-', InputType.zip)).toBe('12345');
});
it('should return just the last four digits when only those are provided', () => {
expect(getFormattedValue('1234', InputType.phone)).toBe('1234');
});
it('should handle partial phone numbers', () => {
expect(getFormattedValue('123', InputType.phone)).toBe('123');
expect(getFormattedValue('1234567', InputType.phone)).toBe('(123) 456-7');
});
});
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 30 days.
Not stale.
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 30 days.
This issue was closed because it has been stalled for 30 days with no activity. Please open a new issue if the issue is still relevant, linking to this one.
This issue was closed because it has been stalled for 30 days with no activity. Please open a new issue if the issue is still relevant, linking to this one.
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.