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

babel-jest 22.2.0 lowered our coverage significantly #5498

Closed
StephanBijzitter opened this issue Feb 8, 2018 · 12 comments
Closed

babel-jest 22.2.0 lowered our coverage significantly #5498

StephanBijzitter opened this issue Feb 8, 2018 · 12 comments

Comments

@StephanBijzitter
Copy link
Contributor

Do you want to request a feature or report a bug?
Bug.

What is the current behavior?
Everything works, but our line coverage compared to 22.1.0 is significantly less, without any code or test changes.

What is the expected behavior?
Everything works, and our line coverage remains the same.

Please provide your exact Jest configuration and mention your Jest, node,
yarn/npm version and operating system.

Content of the script used in package.json:

"jest": "jest --coverage --verbose --runInBand"

Content of babel configuration in package.json:

"babel": {
    "presets": [
      "es2015",
      "react",
      "stage-0"
    ],
    "plugins": [
      [
        "module-resolver",
        {
          "root": [
            "./source",
            "./src"
          ]
        }
      ]
    ]
  },

Content of the configuration file:
https://gist.github.com/StephanBijzitter/036140f1b4c8174018bd45c65360077f

Node 8.9.1 and Yarn 1.3.2, OS X & Ubuntu (Windows not tested)

With babel-jest 22.1.0:
screen shot 2018-02-08 at 16 14 24

With babel-jest 22.2.0:
screen shot 2018-02-08 at 16 15 30

@SimenB
Copy link
Member

SimenB commented Feb 8, 2018

This should be fixed #5496. @mjesun mind releasing a patch?

@dstarosta
Copy link

dstarosta commented Feb 8, 2018

I am not sure if this is related. I am seeing duplicate file records in the coverage output. The secondary lines reduce the coverage because they are not reported with 0 coverage.

The strange part is it only happens in Jenkins jobs. The HTML report also has duplicate lines and low coverage. Downgrading Jest to v21 fixes the issue. I am using the --no-cache option.

Here is a partial example:

  ----------------------------------------------------|----------|----------|----------|----------|----------------|
  File                                                |  % Stmts | % Branch |  % Funcs |  % Lines |Uncovered Lines |
  ----------------------------------------------------|----------|----------|----------|----------|----------------|
  All files                                           |    27.32 |    34.66 |    39.49 |    27.55 |                |
   src                                                |    33.33 |      100 |      100 |    33.33 |                |
    auth-functions.js                                 |      100 |      100 |      100 |      100 |                |
    auth-functions.js                                 |        0 |      100 |      100 |        0 |            3,6 |
   src/actions                                        |    40.17 |       50 |       50 |    39.66 |                |
    authorization-actions.js                          |      100 |      100 |      100 |      100 |                |
    authorization-actions.js                          |        0 |      100 |        0 |        0 |... 46,57,69,80 |
    layout-actions.js                                 |      100 |      100 |      100 |      100 |                |
    layout-actions.js                                 |        0 |      100 |        0 |        0 |... 2,83,96,108 |
    unit-history-actions.js                           |      100 |      100 |      100 |      100 |                |
    unit-history-actions.js                           |        0 |        0 |        0 |        0 |... 83,87,88,90 |

@msholty-fd
Copy link

msholty-fd commented Feb 8, 2018

If you're running into this issue without changing your jest version, set "retainLines": true in your repo's .babelrc. I'm not 100% sure of the implications but from the documentation it appears it's just a line number thing for sourcemaps?

@dstarosta
Copy link

"retainLines": true in the .baberc did not fix my issue.

@SimenB
Copy link
Member

SimenB commented Feb 9, 2018

Oh, if adding retainLines didn't help, then it's another issue... Are you able to create a reproduction case?

@dstarosta
Copy link

dstarosta commented Feb 9, 2018

The problem is it only happens when the build process is running on Jenkins build server.

@ghost
Copy link

ghost commented Feb 28, 2018

I think i have the same issue here on Windows 10.
It only happens in libs\gates...

PASS libs\shared\src\pipes\key-value.pipe.spec.ts
PASS libs\shared\src\statemanagement\reducers\full-screen.spec.ts
PASS libs\gates\src\services\gates.service.spec.ts
FAIL libs\gates\src\services\gates.service.spec.ts
● Test suite failed to run

No file coverage available for: C:\Bert\fe\fe-parts\libs\gates\src\services\gates.service.ts
  
  at CoverageMap.fileCoverageFor (node_modules/istanbul-lib-coverage/lib/coverage-map.js:96:15)
      at Array.forEach (<anonymous>)

PASS libs\gates\src\containers\create-gate\create-gate.component.spec.ts
FAIL libs\gates\src\containers\create-gate\create-gate.component.spec.ts
● Test suite failed to run

No file coverage available for: C:\Bert\fe\fe-parts\libs\gates\src\services\gates.service.ts
  
  at CoverageMap.fileCoverageFor (node_modules/istanbul-lib-coverage/lib/coverage-map.js:96:15)
      at Array.forEach (<anonymous>)

@StephanBijzitter
Copy link
Contributor Author

@BertDuyck seems to be a different issue, because my issue doesn't produce any errors.

@SimenB
Copy link
Member

SimenB commented Mar 1, 2018

@StephanBijzitter Is it still an issue with the latest version of Jest? If yes, can you set up a reproduction case so we can debug?

@BertDuyck I wonder if your issue is related to #5428?

@ghost
Copy link

ghost commented Mar 1, 2018

@SimenB It only happens in one lib, while i have other libs generated the same way with no duplicates.
A workaround for me is to run jest with --no-cache.

@SimenB
Copy link
Member

SimenB commented Feb 3, 2019

Without a reproduction, this is not actionable. Please test with Jest 24 (which has upgraded babel and istanbul dependencies). If it's still an issue, open up a new issue (with a reproduction)

@SimenB SimenB closed this as completed Feb 3, 2019
@github-actions
Copy link

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 github-actions bot locked as resolved and limited conversation to collaborators May 12, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants