gotwarlost / istanbul

Yet another JS code coverage tool that computes statement, line, function and branch coverage with module loader hooks to transparently add coverage when running tests. Supports all JS coverage use cases including unit tests, server side functional tests and browser tests. Built for scale.
Other
8.7k stars 786 forks source link

Cannot read property 'loc' of undefined #929

Open haf opened 4 years ago

haf commented 4 years ago

Report from using the nyc project, but crashing inside this library (node.loc presumably).

Output:

$ yarn coverage:report
yarn run v1.22.0
$ nyc report --reporter=lcov --report-dir=./coverage
Cannot read property 'loc' of undefined
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Comes from running this

$ nyc report --reporter=lcov --report-dir=./coverage"

No other contextual info available. I haven't found a way to bump logging levels.

There's this in package.config:

  "nyc": {
    "extends": "@istanbuljs/nyc-config-typescript",
    "all": true,
    "report-dir": "./coverage",
    "reporters": [
      "lcov",
      "text",
      "test-summary"
    ],
    "exclude": [
      "pages/api/__coverage__.js"
    ]
  },

...but nyc seems to prefer taking its reporters from command line.


nyc@^15.0.0:
  version "15.0.0"
  resolved "https://registry.yarnpkg.com/nyc/-/nyc-15.0.0.tgz#eb32db2c0f29242c2414fe46357f230121cfc162"
  integrity sha512-qcLBlNCKMDVuKb7d1fpxjPR8sHeMVX0CHarXAVzrVWoFrigCkYR8xcrjfXSPi5HXM7EU78L6ywO7w1c5rZNCNg==
  dependencies:
    "@istanbuljs/load-nyc-config" "^1.0.0"
    "@istanbuljs/schema" "^0.1.2"
    caching-transform "^4.0.0"
    convert-source-map "^1.7.0"
    decamelize "^1.2.0"
    find-cache-dir "^3.2.0"
    find-up "^4.1.0"
    foreground-child "^2.0.0"
    glob "^7.1.6"
    istanbul-lib-coverage "^3.0.0"
    istanbul-lib-hook "^3.0.0"
    istanbul-lib-instrument "^4.0.0"
    istanbul-lib-processinfo "^2.0.2"
    istanbul-lib-report "^3.0.0"
    istanbul-lib-source-maps "^4.0.0"
    istanbul-reports "^3.0.0"
    js-yaml "^3.13.1"
    make-dir "^3.0.0"
    node-preload "^0.2.0"
    p-map "^3.0.0"
    process-on-spawn "^1.0.0"
    resolve-from "^5.0.0"
    rimraf "^3.0.0"
    signal-exit "^3.0.2"
    spawn-wrap "^2.0.0"
    test-exclude "^6.0.0"
    uuid "^3.3.3"
    yargs "^15.0.2"

"@istanbuljs/load-nyc-config@^1.0.0":
  version "1.0.0"
  resolved "https://registry.yarnpkg.com/@istanbuljs/load-nyc-config/-/load-nyc-config-1.0.0.tgz#10602de5570baea82f8afbfa2630b24e7a8cfe5b"
  integrity sha512-ZR0rq/f/E4f4XcgnDvtMWXCUJpi8eO0rssVhmztsZqLIEFA9UUP9zmpE0VxlM+kv/E1ul2I876Fwil2ayptDVg==
  dependencies:
    camelcase "^5.3.1"
    find-up "^4.1.0"
    js-yaml "^3.13.1"
    resolve-from "^5.0.0"

"@istanbuljs/nyc-config-typescript@^1.0.1":
  version "1.0.1"
  resolved "https://registry.yarnpkg.com/@istanbuljs/nyc-config-typescript/-/nyc-config-typescript-1.0.1.tgz#55172f5663b3635586add21b14d42ca94a163d58"
  integrity sha512-/gz6LgVpky205LuoOfwEZmnUtaSmdk0QIMcNFj9OvxhiMhPpKftMgZmGN7jNj7jR+lr8IB1Yks3QSSSNSxfoaQ==
  dependencies:
    "@istanbuljs/schema" "^0.1.2"

"@istanbuljs/schema@^0.1.2":
  version "0.1.2"
  resolved "https://registry.yarnpkg.com/@istanbuljs/schema/-/schema-0.1.2.tgz#26520bf09abe4a5644cd5414e37125a8954241dd"
  integrity sha512-tsAQNx32a8CoFhjhijUIhI4kccIAgmGhy8LZMZgGfmXcpMbPRUqn5LWmgRttILi6yeGmBJd2xsPkFMs0PzgPCw==

This may because multiple runs of the test suite generates slightly different files but doesn't manage old files in .nyc_output, as deleting the dotfolder seems to remove the error.

I also get this warning, that I have no idea what to do with;

[0] [0]  WARN lifecycle The node binary used for scripts is /var/folders/cc/70yk9qg16hj0kx5_5r_vq_y40000gn/T/yarn--1584505686271-0.4068172798316103/node but npm is using /Users/h/.nvm/versions/node/v11.12.0/bin/node itself. Use the `--scripts-prepend-node-path` option to include the path for the node binary npm was executed with.