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@14 fails with error: Cannot read property 'children' of undefined #1067

Closed
1 task done
clementallen opened this issue Apr 16, 2019 · 2 comments · Fixed by #1068
Closed
1 task done

nyc@14 fails with error: Cannot read property 'children' of undefined #1067

clementallen opened this issue Apr 16, 2019 · 2 comments · Fixed by #1068

Comments

@clementallen
Copy link

Link to bug demonstration repository

https://github.com/clementallen/smithers/tree/greenkeeper/nyc-14.0.0

MR with failing travis build: clementallen/smithers#93

Failing build log: https://travis-ci.org/clementallen/smithers/jobs/520704518

Expected Behavior

Coverage should run with no errors

Observed Behavior

The following error occurs:

/www/smithers/node_modules/nyc/index.js:440
      if (parentInfo.children.indexOf(info.uuid) === -1) {
                     ^

TypeError: Cannot read property 'children' of undefined
    at infos.forEach.info (/www/smithers/node_modules/nyc/index.js:440:22)
    at Array.forEach (<anonymous>)
    at NYC.writeProcessIndex (/www/smithers/node_modules/nyc/index.js:437:9)
    at /www/smithers/node_modules/nyc/bin/nyc.js:68:9
    at ChildProcess.<anonymous> (/www/smithers/node_modules/foreground-child/index.js:52:5)
    at ChildProcess.emit (events.js:189:13)
    at maybeClose (internal/child_process.js:970:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:259:5)

Troubleshooting steps

  • still occurring when I put cache: false in my nyc config

Environment Information

  System:
    OS: macOS Mojave 10.14.4
    CPU: (4) x64 Intel(R) Core(TM) i5-6360U CPU @ 2.00GHz
    Memory: 156.02 MB / 8.00 GB
  Binaries:
    Node: 10.15.3 - ~/.nvm/versions/node/v10.15.3/bin/node
    npm: 6.4.1 - ~/.nvm/versions/node/v10.15.3/bin/npm
  npmPackages:
    @babel/cli: ^7.4.3 => 7.4.3 
    @babel/core: ^7.4.3 => 7.4.3 
    @babel/polyfill: ^7.4.3 => 7.4.3 
    @babel/preset-env: ^7.4.2 => 7.4.2 
    @babel/register: ^7.4.0 => 7.4.0 
    babel-plugin-add-module-exports: ^1.0.0 => 1.0.0 
    nyc: ^14.0.0 => 14.0.0 
@coreyfarrell
Copy link
Member

It looks like this is happening because nyc is run from inside nyc. Your npm run cover target runs nyc npm test, then npm test also runs nyc. You can work around this error by changing your cover script to npm test && nyc report --reporter=lcov. This will maintain the existing behavior of your testing where lcov report is only generated for the npm run cover target.

I'm going to leave this ticket open as it is something we need to investigate / fix but my advice is to implement the work-around I've mentioned to avoid running nyc inside nyc.

CC @isaacs

@clementallen
Copy link
Author

Thanks @coreyfarrell fixed in clementallen/smithers#94

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

Successfully merging a pull request may close this issue.

2 participants