GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Coverage map issued on switch statements without scoped case clauses incorrectly report an uncovered block · Issue #53652 · nodejs/node

Coverage map issued on switch statements without scoped case clauses incorrectly report an uncovered block #53652

New issue
Copy link
New issue
Copy link
Closed as not planned
Closed as not planned
Coverage map issued on switch statements without scoped case clauses incorrectly report an uncovered block#53652
Copy link
Labels
coverageIssues and PRs related to Node.js code coverage support.Issues and PRs related to Node.js code coverage support.staleIssues and PRs marked stale due to inactivity and scheduled for automatic closure.Issues and PRs marked stale due to inactivity and scheduled for automatic closure.v8 engineIssues and PRs related to the V8 dependency.Issues and PRs related to the V8 dependency.

Description

@ericmorand
ericmorand
opened on Jun 30, 2024
Issue body actions

Version

v20.13.0

Platform

Linux 6.5.0-35-generic #35~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Tue May  7 09:00:52 UTC 2 x86_64 x86_64 x86_64 GNU/Linux

Subsystem

No response

What steps will reproduce the bug?

Consider the following scripts:

  • lib.mjs
export const foo = (value) => {
    switch (value) {
        case true:
            const result = 5;
            return result;
        default:
            return 10;
    }
};
  • index.mjs
import {foo} from "./lib.mjs";

foo(false);
foo(true);

Executing the index.mjs script with node alongside the NODE_V8_COVERAGE environment variable, the output coverage map incorrectly shows the line 9 of lib.mjs (};) as uncovered.

NODE_V8_COVERAGE=./coverage node index.mjs

The coverage map file, with only the two relevant scripts for readability:

{
  "result": [
    {
      "scriptId": "100",
      "url": "file:///home/ericmorand/Projects/one-hundred-cases/src/switch-without-scoped-cases/index.mjs",
      "functions": [
        {
          "functionName": "",
          "ranges": [
            {
              "startOffset": 0,
              "endOffset": 54,
              "count": 1
            }
          ],
          "isBlockCoverage": true
        }
      ]
    },
    {
      "scriptId": "101",
      "url": "file:///home/ericmorand/Projects/one-hundred-cases/src/switch-without-scoped-cases/lib.mjs",
      "functions": [
        {
          "functionName": "",
          "ranges": [
            {
              "startOffset": 0,
              "endOffset": 178,
              "count": 1
            }
          ],
          "isBlockCoverage": true
        },
        {
          "functionName": "foo",
          "ranges": [
            {
              "startOffset": 19,
              "endOffset": 176,
              "count": 2
            },
            {
              "startOffset": 61,
              "endOffset": 128,
              "count": 1
            },
            {
              "startOffset": 137,
              "endOffset": 168,
              "count": 1
            },
            {
              "startOffset": 174,
              "endOffset": 175,
              "count": 0
            }
          ],
          "isBlockCoverage": true
        }
      ]
    }
  ]
}

How often does it reproduce? Is there a required condition?

It happens only when using either:

  • a variable assignment that is immediately returned

The following variant of lib.mjs is not impacted:

export const foo = (value) => {
    switch (value) {
        case true:
            return 5;
        default:
            return 10;
    }
};
  • unscoped case clauses

The following variant of lib.mjs is not impacted:

export const foo = (value) => {
    switch (value) {
        case true: {
            const result = 5;
            return result;
        }
        default: {
            return 10;
        }
    }
};

What is the expected behavior? Why is that the expected behavior?

The entirety of lib.mjs should be shown as covered.

What do you see instead?

The range 174:175 is considered as uncovered:

{
  "startOffset": 174,
  "endOffset": 175,
  "count": 0
}

Additional information

This issues has been impacting c8, among other code coverage tools:

bcoe/c8#497

Activity

  1. avivkeller
    added
    coverageIssues and PRs related to Node.js code coverage support.Issues and PRs related to Node.js code coverage support.
    on Jun 30, 2024
  2. juanarbol commented on Jun 30, 2024

    @juanarbol
    juanarbol
    on Jun 30, 2024
    Member
    More actions

    You should open an issue in V8. From the Node-side there’s not that much we can do.

  3. juanarbol
    added
    v8 engineIssues and PRs related to the V8 dependency.Issues and PRs related to the V8 dependency.
    on Jun 30, 2024
  4. ericmorand commented on Jun 30, 2024

    @ericmorand
    ericmorand
    on Jun 30, 2024
    Author
    More actions

    @juanarbol , I agree and I would, but the only thing I know is that it fails when using Node.js: I have no idea how Node.js itself propagates this environment variable to V8. I'm afraid that if I open an issue there, explaining exactlty what I explain in the current issue, they will answer "this is a Node.js issue, open an issue to their repository".

    I need to know what Node.js is doing with this environment variable so that I can open an issue at V8. And for that, I'm afraid I need your help.

  5. juanarbol commented on Jun 30, 2024

    @juanarbol
    juanarbol
    on Jun 30, 2024
    Member
    More actions

    Node.js simply uses the V8’s inspector protocol for this. And Node.js or C8 gets all the output collected from the V8, is it not manipulated, nor the scripts are instrumented by Node.js, everything is V8, Node.js simply bypasses the output.

  6. github-actions commented on May 7, 2026

    @github-actions
    github-actionsBot
    on May 7, 2026 – with GitHub Actions
    Contributor
    More actions

    This issue has been marked as stale due to 210 days of inactivity.
    It will be automatically closed in 30 days if no further activity occurs. If this is still relevant, please leave a comment or update it to keep it open.

  7. github-actions
    added
    staleIssues and PRs marked stale due to inactivity and scheduled for automatic closure.Issues and PRs marked stale due to inactivity and scheduled for automatic closure.
    on May 7, 2026
  8. github-actions commented on Jun 6, 2026

    @github-actions
    github-actionsBot
    on Jun 6, 2026 – with GitHub Actions
    Contributor
    More actions

    This issue has been automatically closed after 30 days of inactivity following its stale status (no activity for a total of 240 days).
    If this is still relevant, feel free to reopen it or leave a comment with additional details so we can continue the discussion.

  9. github-actions
    closed this as not plannedon Jun 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    coverageIssues and PRs related to Node.js code coverage support.Issues and PRs related to Node.js code coverage support.staleIssues and PRs marked stale due to inactivity and scheduled for automatic closure.Issues and PRs marked stale due to inactivity and scheduled for automatic closure.v8 engineIssues and PRs related to the V8 dependency.Issues and PRs related to the V8 dependency.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402520 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.