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

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


Copy link

commented Apr 16, 2019

Link to bug demonstration repository

MR with failing travis build: clementallen/smithers#93

Failing build log:

Expected Behavior

Coverage should run with no errors

Observed Behavior

The following error occurs:

      if (parentInfo.children.indexOf(info.uuid) === -1) {

TypeError: Cannot read property 'children' of undefined
    at (/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

    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
    Node: 10.15.3 - ~/.nvm/versions/node/v10.15.3/bin/node
    npm: 6.4.1 - ~/.nvm/versions/node/v10.15.3/bin/npm
    @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 

This comment has been minimized.

Copy link

commented Apr 16, 2019

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


This comment has been minimized.

Copy link

commented Apr 16, 2019

Thanks @coreyfarrell fixed in clementallen/smithers#94

coreyfarrell added a commit to coreyfarrell/nyc that referenced this issue Apr 16, 2019
coreyfarrell added a commit that referenced this issue Apr 16, 2019
Fixes #1067
@rofe rofe referenced this issue Apr 24, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
2 participants
You can’t perform that action at this time.