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 failing sometimes on Bitbucket's Pipeline #706

Closed
andre991 opened this issue Nov 1, 2017 · 13 comments
Closed

nyc failing sometimes on Bitbucket's Pipeline #706

andre991 opened this issue Nov 1, 2017 · 13 comments

Comments

@andre991
Copy link

andre991 commented Nov 1, 2017

I tried to run nyc in bitbucket's pipeline, but sometimes the builds fails with this error. However, running locally on my machine, this error does not occur.

nyc version: 11.2.1
OS(Local): macOS High Sierra 10.13
OS(Pipeline): Linux 4.13.5-coreos-r2
npm version: 3.10.10
node version: 6.9.4

npm info ok
/opt/atlassian/pipelines/agent/build/node_modules/nyc/node_modules/istanbul-lib-source-maps/lib/transformer.js:97
mappedCoverage.addStatement(mapping.loc, hits);
^
TypeError: mappedCoverage.addStatement is not a function
at /opt/atlassian/pipelines/agent/build/node_modules/nyc/node_modules/istanbul-lib-source-maps/lib/transformer.js:97:28
at Array.forEach (native)
at SourceMapTransformer.processFile (/opt/atlassian/pipelines/agent/build/node_modules/nyc/node_modules/istanbul-lib-source-maps/lib/transformer.js:88:34)
at /opt/atlassian/pipelines/agent/build/node_modules/nyc/node_modules/istanbul-lib-source-maps/lib/transformer.js:169:24
at Array.forEach (native)
at SourceMapTransformer.transform (/opt/atlassian/pipelines/agent/build/node_modules/nyc/node_modules/istanbul-lib-source-maps/lib/transformer.js:159:25)
at MapStore.transformCoverage (/opt/atlassian/pipelines/agent/build/node_modules/nyc/node_modules/istanbul-lib-source-maps/lib/map-store.js:143:8)
at SourceMaps.remapCoverage (/opt/atlassian/pipelines/agent/build/node_modules/nyc/lib/source-maps.js:29:41)
at NYC._getCoverageMapFromAllCoverageFiles (/opt/atlassian/pipelines/agent/build/node_modules/nyc/index.js:426:30)
at NYC.report (/opt/atlassian/pipelines/agent/build/node_modules/nyc/index.js:432:18)
npm info lifecycle dsm-api@1.0.0~unit-coverage: Failed to exec unit-coverage script
npm ERR! Linux 4.13.5-coreos-r2
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "unit-coverage"
npm ERR! node v6.9.4
npm ERR! npm v3.10.10
npm ERR! code ELIFECYCLE
npm ERR! dsm-api@1.0.0 unit-coverage: nyc --reporter=lcovonly npm run unit-test
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the dsm-api@1.0.0 unit-coverage script 'nyc --reporter=lcovonly npm run unit-test'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the dsm-api package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! nyc --reporter=lcovonly npm run unit-test
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs dsm-api
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls dsm-api
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /opt/atlassian/pipelines/agent/build/npm-debug.log

@brollins90
Copy link

I see the same error intermittently on travis TypeError: mappedCoverage.addStatement is not a function.

@arupadhy
Copy link

arupadhy commented Nov 16, 2017

any updates/work around on this? i was planning to use this and it seems to fail intermittently with the above error

@bcoe
Copy link
Member

bcoe commented Nov 20, 2017

@andre991, @arupadhy, @brollins90 would any of you be able to share a codebase that is having this issue?

Once we have a repo that reproduces this issue, perhaps we can release a version of nyc that has a debug statement in transformer.js ... what is the object that it's trying to call addStatement on?

@arupadhy
Copy link

@bcoe unfortunately, i can't share the codebase. This does not happen in every run. Can't promise but I will try to create a public typescript project with the above problem in coming week

@bcoe
Copy link
Member

bcoe commented Nov 28, 2017

@arupadhy oh, that's a useful piece of information that you're using TypeScript; are you also using --all? try dropping the use of --all if you are, and see if builds continue failing. If this is the culprit, I can follow up with a workaround (that will allow you to continue using --all).

@arupadhy
Copy link

Tried removing --all option, no luck yet.

here is the trace
TypeError: mappedCoverage.addStatement is not a function
at /srv/package/node_modules/nyc/node_modules/istanbul-lib-source-maps/lib/transformer.js:97:28
at Array.forEach (native)
at SourceMapTransformer.processFile (/srv/package/node_modules/nyc/node_modules/istanbul-lib-source-maps/lib/transformer.js:88:34)
at /srv/package/node_modules/nyc/node_modules/istanbul-lib-source-maps/lib/transformer.js:169:24
at Array.forEach (native)
at SourceMapTransformer.transform (/srv/package/node_modules/nyc/node_modules/istanbul-lib-source-maps/lib/transformer.js:159:25)
at MapStore.transformCoverage (/srv/package/node_modules/nyc/node_modules/istanbul-lib-source-maps/lib/map-store.js:143:8)
at SourceMaps.remapCoverage (/srv/package/node_modules/nyc/lib/source-maps.js:29:41)
at NYC._getCoverageMapFromAllCoverageFiles (/srv/package/node_modules/nyc/index.js:415:30)
at NYC.report (/srv/package/node_modules/nyc/index.js:421:18)

npm info lifecycle composite-service@0.42.1~check-coverage: Failed to exec check-coverage script

This is how "check-coverage" is declared

"check-coverage": "NODE_ENV=test LOG_LEVEL=info nyc --report-dir spec/coverage --reporter cobertura --reporter html npm run test-coverage"

"test-coverage": "NODE_ENV=test ./node_modules/mocha/bin/_mocha --timeout 30000 -R mocha-multi --reporter-options spec=-,xunit=spec/reports/xunit.xml './dist/spec/unit///*.js'"

@JaKXz
Copy link
Member

JaKXz commented Nov 28, 2017

Just curious, does your setup look something like this? https://istanbul.js.org/docs/tutorials/typescript/

@arupadhy
Copy link

this is how my .nycrc looks {
"check-coverage": false,
"exclude": [
"dist",
"spec"
]
}

Rest of the options for nyc are used within the script (see ^^)

@arupadhy
Copy link

arupadhy commented Jan 4, 2018

@team was this issue reproducible at your end?

@mbradburn
Copy link

This was failing reliably with our project; I whittled things down to the minimum that would still fail reliably, and that whittled result is available at https://github.com/mbradburn/istanbul-test-case

The stack trace looks like:

/Users/mjb/w2/istanbul-test-case/node_modules/nyc/node_modules/istanbul-lib-source-maps/lib/transformer.js:97
mappedCoverage.addStatement(mapping.loc, hits);
^

TypeError: mappedCoverage.addStatement is not a function
at /Users/mjb/w2/istanbul-test-case/node_modules/nyc/node_modules/istanbul-lib-source-maps/lib/transformer.js:97:28
at Array.forEach ()
at SourceMapTransformer.processFile (/Users/mjb/w2/istanbul-test-case/node_modules/nyc/node_modules/istanbul-lib-source-maps/lib/transformer.js:88:34)
at /Users/mjb/w2/istanbul-test-case/node_modules/nyc/node_modules/istanbul-lib-source-maps/lib/transformer.js:169:24
at Array.forEach ()
at SourceMapTransformer.transform (/Users/mjb/w2/istanbul-test-case/node_modules/nyc/node_modules/istanbul-lib-source-maps/lib/transformer.js:159:25)
at MapStore.transformCoverage (/Users/mjb/w2/istanbul-test-case/node_modules/nyc/node_modules/istanbul-lib-source-maps/lib/map-store.js:143:8)
at SourceMaps.remapCoverage (/Users/mjb/w2/istanbul-test-case/node_modules/nyc/lib/source-maps.js:29:41)
at NYC._getCoverageMapFromAllCoverageFiles (/Users/mjb/w2/istanbul-test-case/node_modules/nyc/index.js:437:30)
at NYC.report (/Users/mjb/w2/istanbul-test-case/node_modules/nyc/index.js:443:18)
npm ERR! Test failed. See above for more details.

@cassioconti
Copy link

I have the same error in VSTS.

@ericsoco
Copy link

ericsoco commented Nov 5, 2018

I'm seeing the same error and stack trace as @mbradburn.
This started happening when moving onto babel-plugin-istanbul.

My .nycrc:

{
  "require": [
    "@babel/register"
  ],
  "reporter": [
    "html",
    "cobertura"
  ],
  "sourceMap": false,
  "instrument": false
}

The script running nyc:

"cover": "nyc lerna run node-test && npm run flow-cover",

Haven't yet tried to isolate/repro, there are plenty of other parts at play (as implied by the lerna call).

@stale
Copy link

stale bot commented Jan 5, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

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

No branches or pull requests

8 participants