jest icon indicating copy to clipboard operation
jest copied to clipboard

[Bug]: Jest coverage is reporting a line as untested

Open Shereef opened this issue 1 year ago • 6 comments

Version

28.1.3

Steps to reproduce

Steps:

  1. Clone https://github.com/Shereef/graphql-jest-coverage-attribute
  2. run npm run test:cov

Expected behavior

Should get 100% coverage

Actual behavior

It's reporting 85.71% because of an attribute @Query(() => String)

Additional context

If you look at this file and delete the attribute parameter to @Query() you will get 100% coverage but the project will not work.

import { Resolver, Query } from '@nestjs/graphql';

@Resolver()
export class AppResolver {
  @Query(() => String)
  getHello(): string {
    return 'Hello World!';
  }
}

Environment

System:
    OS: macOS 13.0.1
    CPU: (10) arm64 Apple M1 Pro
  Binaries:
    Node: 16.14.2 - /usr/local/bin/node
    npm: 8.19.2 - ~/node_modules/.bin/npm
  npmPackages:
    jest: 28.1.3 => 28.1.3

Shereef avatar Nov 18 '22 20:11 Shereef

I didn't know which package introduced this so I also filed this https://github.com/istanbuljs/istanbuljs/issues/707

Shereef avatar Nov 18 '22 21:11 Shereef

Did you find a solution?

davidediak avatar Dec 15 '22 07:12 davidediak

Did you find a solution?

No sir, just put /* istanbul ignore next */ before the arrow function

P.S. I hand typed this comment from my phone Please spell check the code

Shereef avatar Dec 15 '22 11:12 Shereef

Hey, thanks for answering, but my issue was regarding an nx/Angular project, so a case different from yours.

I found the solution here

davidediak avatar Dec 16 '22 14:12 davidediak

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 Jan 15 '23 14:01 github-actions[bot]

Any update on this ?

Shereef avatar Jan 16 '23 16:01 Shereef

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 Feb 15 '23 16:02 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 Mar 17 '23 16:03 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 Apr 17 '23 00:04 github-actions[bot]