Skip to content
This repository has been archived by the owner on Dec 8, 2024. It is now read-only.

'Branch not covered' #582

Open
willin opened this issue Mar 24, 2016 · 16 comments
Open

'Branch not covered' #582

willin opened this issue Mar 24, 2016 · 16 comments

Comments

@willin
Copy link

willin commented Mar 24, 2016

qq20160324-1 2x

is it a bug or other?

@guyellis
Copy link

Are you using Babel? I've seen this show up when I have a combo of Babel transpilation and Istanbul.

@willin
Copy link
Author

willin commented Mar 25, 2016

yes.

{
    "babel-plugin-transform-runtime": "^6.6.0",
    "babel-preset-es2015": "^6.6.0",
    "babel-preset-es2015-loose": "^7.0.0",
    "babel-preset-stage-1": "^6.5.0",
    "babel-register": "^6.7.2",
    "babel-runtime": "^6.6.1",
}

@guyellis
Copy link

One of the current alpha branches might address that: https://github.com/gotwarlost/istanbul/releases

@JoelOtter
Copy link

I'm still seeing this issue on v0.4.3, which I believe is later than the mentioned alpha releases.

@otbe
Copy link

otbe commented Jun 14, 2016

I wonder if this is also the root of some uncovered branches in my current project.

bildschirmfoto 2016-06-14 um 16 13 36

Im using typescript & babel and all other branches are fine. Obviously it was covered (green "1x" on the left side).

It is the same problem?

Tried already the latest apha, but issue still exists.

@morficus
Copy link

I have a similar issue (some branches now showing as covered) and I found it curious that everyone here is using typeof (which I was as well).

After reading this I decided use instanceof instead and bam! all branches covered.

@smonusbonus
Copy link

Hmm yeah same issue here with typeof.
screen shot 2017-04-06 at 09 54 27

@AlexMiroshnikov
Copy link

A very basic and tiny sample of the same kind of misbehavior:
codecov-typeof-problem

@tpizza
Copy link

tpizza commented Jul 13, 2017

Yet another example of the misbehavior:

image

@Biglr
Copy link

Biglr commented Jul 15, 2017

I have a similar problem, only that it is with commas as well:

capture

2017-07-15_163024

I've got a lot of those kinds of "branch not covered" warnings all over my applications...

@AshCoolman
Copy link

AshCoolman commented Jul 29, 2017

typeof also giving me problems

screen shot 2017-07-29 at 08 37 22

Update Changing to 1.0.0-alpha.2 works for me

@QuentinRoy
Copy link

QuentinRoy commented Oct 6, 2017

I believe this is because babel replaces typeof with a custom helper that branches in function of the environment (hence only one branch is executed per environment).

@savcni01
Copy link

savcni01 commented Oct 10, 2017

@QuentinRoy - yes, I think you are right: Babel Transformation Example

So for @AshCoolman example for cover all branches you need to provide 2 variants of element:

element = undefined
//and
element = 'some sting'
// then
const typeOfElement = typeof(element)

will run both branches hidden at babel replacement of typeof

@QuentinRoy
Copy link

For your information, with ava, I made it work with the following config:

.babelrc

{
  "presets": ["env"],
  "env": {
    "test": {
      "plugins": [ "istanbul" ],
      "presets": [["env", { "targets": { "node": "current" } }]]
    }
  }
}

package.json

{
  // [...]
  "ava": {
    "require": [
      "babel-register"
    ]
  },
  "nyc": {
    "sourceMap": false,
    "instrument": false
  }
}

@cope
Copy link

cope commented Feb 12, 2018

I think this is the same problem:
image

I'm testing with null as well as with both valid and invalid string and object definition parameter.

Same happens in this case:
image

I get a 100% Branches only if I use definition = definition || '';, which is not making me happy. I like the ES6 default parameters :(

@adamreisnz
Copy link

Finding it impossible to fix this issue.

Always resulting tin the following error:
image

Even if using the suggested fix:
image

I'm running tests and passing both strings, undefined, and valid objects to the glob param.

Even when I use //istanbul ignore if it still reports it.

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