Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Jest showing wrong coverage report #15229

Closed
lucaslacerdacl opened this issue Aug 1, 2024 · 10 comments
Closed

[Bug]: Jest showing wrong coverage report #15229

lucaslacerdacl opened this issue Aug 1, 2024 · 10 comments

Comments

@lucaslacerdacl
Copy link

lucaslacerdacl commented Aug 1, 2024

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
@krishnabrq
Copy link

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

Copy link

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 github-actions bot added the Stale label Sep 17, 2024
@lucaslacerdacl
Copy link
Author

This still happening

@github-actions github-actions bot removed the Stale label Sep 25, 2024
@marc-uhlig
Copy link

I'm experiencing the same error with 29.7.0.

@pandeykushagra51
Copy link

pandeykushagra51 commented Oct 27, 2024

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

Copy link

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 github-actions bot added the Stale label Nov 26, 2024
@krishnabrq
Copy link

Not stale.

@github-actions github-actions bot removed the Stale label Nov 27, 2024
Copy link

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 github-actions bot added the Stale label Dec 27, 2024
Copy link

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.

1 similar comment
Copy link

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 github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Jan 26, 2025
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Jan 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants