jest icon indicating copy to clipboard operation
jest copied to clipboard

[Bug]: Jest showing wrong coverage report

Open lucaslacerdacl opened this issue 1 year ago • 4 comments

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. Screenshot 2024-08-01 at 10 05 18

Screenshot 2024-08-01 at 10 03 19 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

lucaslacerdacl avatar Aug 01 '24 13:08 lucaslacerdacl

Facing the same issue. Screenshot 2024-08-18 at 7 36 22 AM

krishnabrq avatar Aug 18 '24 02:08 krishnabrq

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.

github-actions[bot] avatar Sep 17 '24 02:09 github-actions[bot]

This still happening

lucaslacerdacl avatar Sep 25 '24 20:09 lucaslacerdacl

I'm experiencing the same error with 29.7.0.

marc-uhlig avatar Oct 01 '24 13:10 marc-uhlig

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');
  });
});

pandeykushagra51 avatar Oct 27 '24 17:10 pandeykushagra51

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.

github-actions[bot] avatar Nov 26 '24 18:11 github-actions[bot]

Not stale.

krishnabrq avatar Nov 27 '24 05:11 krishnabrq

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.

github-actions[bot] avatar Dec 27 '24 07:12 github-actions[bot]

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.

github-actions[bot] avatar Jan 26 '25 08:01 github-actions[bot]

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.

github-actions[bot] avatar Jan 26 '25 08:01 github-actions[bot]

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.

github-actions[bot] avatar Feb 26 '25 00:02 github-actions[bot]