# False partials in code coverage (JavaScript / Typescript)

**URL:** <https://community.codecov.com/t/false-partials-in-code-coverage-javascript-typescript/2957>\
**Category:** Bug Fixes\
**Created:** [June 10, 2021, 8:04pm UTC](https://community.codecov.com/t/false-partials-in-code-coverage-javascript-typescript/2957 "2021-06-10T20:04:50Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![jsamr](https://yyz1.discourse-cdn.com/flex029/user_avatar/community.codecov.com/jsamr/32/1355_2.png) [@jsamr](https://community.codecov.com/u/jsamr)\
**Post date:** [June 10, 2021, 8:04pm UTC](https://community.codecov.com/t/false-partials-in-code-coverage-javascript-typescript/2957/1 "2021-06-10T20:04:51Z")

</div>

### Description

All the `if`, `switch` and ternary expressions are flagged as partials even though each branch is covered, resulting in a massive underrating of the total coverage. Jest reports a total branch coverage of 99.2% while Codecov, for the same commit, reports 78.42%.

See for example the switch statement here: [Codecov](https://codecov.io/gh/meliorence/react-native-render-html/src/e11a1b30bf18da2d5a429efa7b9c309979f47e5c/packages/render-html/src/elements/extractImageStyleProps.ts), L14.

 ![image](https://canada1.discourse-cdn.com/flex029/uploads/codecov/original/2X/1/1efc6a2f98f50541364fa20b68046f8047bf0581.png)

### Commit SHAs

e11a1b30bf18da2d5a429efa7b9c309979f47e5c

### Repository

> **[GitHub - meliorence/react-native-render-html: iOS/Android pure javascript react-native component...](https://github.com/meliorence/react-native-render-html)**
>
> iOS/Android pure javascript react-native component that renders your HTML into 100% native views

### CI/CD or Build URL

[https://github.com/meliorence/react-native-render-html/runs/2796786027?check\_suite\_focus=true](https://github.com/meliorence/react-native-render-html/runs/2796786027?check_suite_focus=true)

### Uploader

Bash

### Codecov Output

```
/usr/bin/bash codecov.sh -n -F -Q github-action-v1.5.2 -Z -f ./packages/render-html/coverage/clover.xml

  _____ _
 / ____ | | |
| | _____ | | ______  _______
| | / _ \ / _` |/ _ \/ __/ _ \ \ / /
| |___| (_) | (_| |__/ (_| (_) \ V /
 \ _____\___ / \ __,_|\___ |\ ___\___ / \_/
                              Bash-1.0.3

==> git version 2.31.1 found
==> curl 7.68.0 (x86_64-pc-linux-gnu) libcurl/7.68.0 OpenSSL/1.1.1f zlib/1.2.11 brotli/1.0.7 libidn2/2.2.0 libpsl/0.21.0 (+libidn2/2.2.0) libssh/0.9.3/openssl/zlib nghttp2/1.40.0 librtmp/2.3
Release-Date: 2020-01-08
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtmp rtsp scp sftp smb smbs smtp smtps telnet tftp 
Features: AsynchDNS brotli GSS-API HTTP2 HTTPS-proxy IDN IPv6 Kerberos Largefile libz NTLM NTLM_WB PSL SPNEGO SSL TLS-SRP UnixSockets
==> GitHub Actions detected.
    Env vars used:
      -> GITHUB_ACTIONS: true
      -> GITHUB_HEAD_REF:   
      -> GITHUB_REF: refs/heads/master
      -> GITHUB_REPOSITORY: meliorence/react-native-render-html
      -> GITHUB_RUN_ID: 926228010
      -> GITHUB_SHA: e11a1b30bf18da2d5a429efa7b9c309979f47e5c
      -> GITHUB_WORKFLOW: CI
    project root: .
    Yaml not found, that's ok! Learn more at http://docs.codecov.io/docs/codecov-yaml
    -> Found 1 reports
==> Detecting git/mercurial file structure
==> Reading reports
    + ./packages/render-html/coverage/clover.xml bytes=57661
==> Appending adjustments
    https://docs.codecov.io/docs/fixing-reports
    + Found adjustments
==> Gzipping contents
        132K	/tmp/codecov.cP5OCN.gz
==> Uploading reports
    url: https://codecov.io
    query: branch=master&commit=e11a1b30bf18da2d5a429efa7b9c309979f47e5c&build=926228010&build_url=http%3A%2F%2Fgithub.com%2Fmeliorence%2Freact-native-render-html%2Factions%2Fruns%2F926228010&name=&tag=&slug=meliorence%2Freact-native-render-html&service=github-actions&flags=&pr=&job=CI&cmd_args=n,F,Q,Z,f
-> Pinging Codecov
https://codecov.io/upload/v4?package=github-action-v1.5.2-1.0.3&token=secret&branch=master&commit=e11a1b30bf18da2d5a429efa7b9c309979f47e5c&build=926228010&build_url=http%3A%2F%2Fgithub.com%2Fmeliorence%2Freact-native-render-html%2Factions%2Fruns%2F926228010&name=&tag=&slug=meliorence%2Freact-native-render-html&service=github-actions&flags=&pr=&job=CI&cmd_args=n,F,Q,Z,f
-> Uploading to
https://storage.googleapis.com/codecov/v4/raw/2021-06-10/EC2A5C92A55FB6917FC12085982D2423/e11a1b30bf18da2d5a429efa7b9c309979f47e5c/66f3d26f-9676-4e74-8f16-cc20d552c720.txt?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=GOOG1EKKHVKCKHW7KBCGM7IHR55T63V2PAVJWLVFNITJHDU5G6R5IRN3LMWJA%2F20210610%2FUS%2Fs3%2Faws4_request&X-Amz-Date=20210610T192531Z&X-Amz-Expires=10&X-Amz-SignedHeaders=host&X-Amz-Signature=767e109e366d0fdbff27ca176f42368468679e87a980330cfdaa0b8f4b38968e
  % Total % Received % Xferd Average Speed Time Time Time Current
                                 Dload Upload Total Spent Left Speed

  0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
100 131k 0 0 100 131k 0 479k --:--:-- --:--:-- --:--:-- 479k
    -> Reports have been successfully queued for processing at https://codecov.io/github/meliorence/react-native-render-html/commit/e11a1b30bf18da2d5a429efa7b9c309979f47e5c
```

### Expected Results

A codecov coverage above 96-97% (because partial hits are considered missed, I expect a lower rate than with Jest).

### Actual Results

A codecov coverage of 78.42%.

### Additional Information

Might be related to [Ternary coverage in JavaScript](https://community.codecov.com/t/ternary-coverage-in-javascript/2901)

---

<div class="post-metadata">

**Author:** ![tom](https://yyz1.discourse-cdn.com/flex029/user_avatar/community.codecov.com/tom/32/8_2.png) [@tom](https://community.codecov.com/u/tom)\
**Post date:** [June 11, 2021, 6:26pm UTC](https://community.codecov.com/t/false-partials-in-code-coverage-javascript-typescript/2957/2 "2021-06-11T18:26:44Z")

</div>

@jsamr, this is actually coming from the Jest report. See the raw [coverage report](https://codecov.io/gh/meliorence/react-native-render-html/commit/e11a1b30bf18da2d5a429efa7b9c309979f47e5c/build).

```auto
      <file name="extractImageStyleProps.ts" path="/home/runner/work/react-native-render-html/react-native-render-html/packages/render-html/src/elements/extractImageStyleProps.ts">
        <metrics statements="12" coveredstatements="12" conditionals="7" coveredconditionals="7" methods="2" coveredmethods="2"/>
        <line num="6" count="28" type="stmt"/>
        <line num="14" count="10" type="cond" truecount="5" falsecount="0"/>

```

Since `falsecount` is 0, it is considered only partially covered. Codecov considers partial coverage as [not covered](https://docs.codecov.io/docs/frequently-asked-questions#how-is-coverage-calculated).

---

<div class="post-metadata">

**Author:** ![jsamr](https://yyz1.discourse-cdn.com/flex029/user_avatar/community.codecov.com/jsamr/32/1355_2.png) [@jsamr](https://community.codecov.com/u/jsamr)\
**Post date:** [June 11, 2021, 7:40pm UTC](https://community.codecov.com/t/false-partials-in-code-coverage-javascript-typescript/2957/3 "2021-06-11T19:40:32Z")

</div>

But a switch statement would always have 0 “falsecount”, wouldn’t it? Is jest misusing the conditional here? What tag should it use instead?

---

<div class="post-metadata">

**Author:** ![jsamr](https://yyz1.discourse-cdn.com/flex029/user_avatar/community.codecov.com/jsamr/32/1355_2.png) [@jsamr](https://community.codecov.com/u/jsamr)\
**Post date:** [June 11, 2021, 9:16pm UTC](https://community.codecov.com/t/false-partials-in-code-coverage-javascript-typescript/2957/4 "2021-06-11T21:16:32Z")

</div>

The same file with same commit gives a 100% branch coverage with istanbul (which is used by jest):

 ![image](https://canada1.discourse-cdn.com/flex029/uploads/codecov/original/2X/a/a7491bc14a9bc0f867d158f183afda0bd63a2d6f.png)

---

<div class="post-metadata">

**Author:** ![tom](https://yyz1.discourse-cdn.com/flex029/user_avatar/community.codecov.com/tom/32/8_2.png) [@tom](https://community.codecov.com/u/tom)\
**Post date:** [August 25, 2021, 3:56am UTC](https://community.codecov.com/t/false-partials-in-code-coverage-javascript-typescript/2957/5 "2021-08-25T03:56:44Z")

</div>

@jsamr, I’m sorry this got lost from me. I’m not sure why the switch statement would have 0 “falsecount”. I’m guessing there is some nuance that I don’t understand. [This](https://stackoverflow.com/questions/42642840/why-is-jacoco-not-covering-my-string-switch-statements) stackoverflow post might be useful.

I realize it’s been awhile, are you still experiencing an issue here?
