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

nyc merge in nyc@next gives 'Invalid file coverage object, missing keys, found:data' #1226

Open
akoidan opened this issue Nov 18, 2019 · 9 comments

Comments

@akoidan
Copy link

akoidan commented Nov 18, 2019

Link to bug demonstration repository

git clone https://github.com/akoidan/vue-webpack-typescript
git checkout multicov
yarn install
yarn test

Expected Behavior

  • tests are merged, no errors

Observed Behavior

commands in example will run multiple test and then tries to run nyc merge that would fail with error:
'Invalid file coverage object, missing keys, found:data'
To be specific

yarn run test:unit
yarn nyc merge ./nyc/.nyc_output_unit/ ./nyc/.nyc_output/unit.json 

results a json like this:

{
  "/home/andrew/WebstormProjects/vue-webpack-typescript/src/utils/classComponentHooks.ts": {
    "data": {
      "path": "/home/andrew/WebstormProjects/vue-webpack-typescript/src/utils/classComponentHooks.ts",
      "statementMap": {
        "0": {
          "start": {
            "line": 4,
            "column": 0
          },
          "end": {
            "line": 8,
            "column": 3
          }
        }
      },
      "fnMap": {},
      "branchMap": {},
      "s": {
        "0": 0
      },
      "f": {},
      "b": {},
      "all": true
    }
  }
}

Environment Information

npx: installed 1 in 0.76s

  System:
    OS: Linux 5.3 Arch Linux undefined
    CPU: (8) x64 Intel(R) Core(TM) i7-6700HQ CPU @ 2.60GHz
    Memory: 5.92 GB / 31.25 GB
  Binaries:
    Node: 12.13.0 - /usr/bin/node
    Yarn: 1.19.1 - /usr/bin/yarn
    npm: 6.12.1 - /usr/bin/npm
  npmPackages:
    @babel/plugin-proposal-class-properties: 7.7.0 => 7.7.0 
    @babel/plugin-proposal-decorators: 7.7.0 => 7.7.0 
    @babel/preset-env: 7.7.1 => 7.7.1 
    babel-loader: 8.0.6 => 8.0.6 
    babel-plugin-istanbul: 5.2.0 => 5.2.0 
    babel-preset-typescript-vue: 1.0.2 => 1.0.2 
    istanbul-lib-coverage: 2.0.5 => 2.0.5 
    nyc: ^15.0.0-beta.0 => 15.0.0-beta.0 
    source-map-support: 0.5.16 => 0.5.16 
    ts-node: 8.5.2 => 8.5.2 
    typescript: 3.7.2 => 3.7.2 
@coreyfarrell
Copy link
Member

Please upgrade babel-plugin-istanbul and istanbul-lib-coverage to the next versions otherwise you are combining multiple versions of istanbul libraries. Once you've done that assuming this is still an issue can you please commit all of your .nyc_output directories? Thanks.

@coreyfarrell
Copy link
Member

@akoidan I've just released a new beta of nyc which contains at least one fix to source-map processing. Could you give this a try? I've seen TypeError: Cannot read property 'start' of undefined before, it's often the result of merging sources with incompatible source-maps.

Please be aware your issue is a bit difficult as it is so large. If 15.0.0-beta.1 does not work I'd like for you to commit your nyc directory. I'd like to take a look at the HTML report difference you mentioned as well as the raw .nyc_output files.

@akoidan
Copy link
Author

akoidan commented Nov 18, 2019

Duplication information here for future readers:

With @next the issue seems to be gone from nyc mocha with ts-node, but when I merge 2 outputs from cypress and mocha and then do a report I'm still getting the same issue:

At least it's always determenistic now, I always get:

TypeError: Cannot read property 'start' of undefined

Note that if you check

  • ./nyc/coverage_cypress/src/utils/xhr.ts.html
  • ./nyc/coverage_unit/xhr.ts.html

they are both ok. And it's werid that the format of output html is different

@akoidan
Copy link
Author

akoidan commented Nov 18, 2019

@coreyfarrell You can always get the report by runnign steps I specified above. Anyway I commited the files as you asked (mind the branch nyc):

https://github.com/akoidan/vue-webpack-typescript/tree/nyc/issues/1226/nyc

@akoidan
Copy link
Author

akoidan commented Nov 25, 2019

@coreyfarrell any updates? Do you need any help from my side?

@coreyfarrell
Copy link
Member

@akoidan I'm very busy so I have to ask for your patience.

@akoidan
Copy link
Author

akoidan commented Oct 1, 2020

@coreyfarrell any updates? ^^

@Maximus1285
Copy link

I'm running into this issue as well.

@quisido
Copy link

quisido commented Dec 22, 2021

I was able to resolve this by just updating babel-plugin-istanbul with yarn up -R babel-plugin-istanbul. Cypress's code coverage package hard locks us to istanbul-lib-coverage@3.0.0, but the fact that the other dependencies used 3.2.x did not impact this.

The found:data error was a result of one babel-plugin-istanbul being 6.0 and the other being 6.1.

EDIT: For a second project, I had to upgrade both via yarn up -R babel-plugin-istanbul istanbul-lib-coverage.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants