by

Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Albert Salim
    @caalberts
    i have set up nyc within my npm test script and was able to execute the tests, but the coverage result shows 100% coverage everywhere, which is not right
    hoping someone here can help me identify what's wrong
    my package.json setup:
    "babel": {
        "presets": ["es2015"],
        "env": {
          "test": {
            "plugins": ["istanbul"]
          }
        }
      },
      "nyc": {
        "require": [
          "babel-register"
        ],
        "exclude": [
          "app/lib/*",
          "assets/*"
        ],
        "sourceMap": false,
        "instrument": false
      }
    test script:
    "test:coverage": "NODE_ENV=test nyc mocha app/test --recursive --compilers js:babel-register --require ignore-styles --require app/test/jsdom-setup"
    Albert Salim
    @caalberts
    Screen Shot 2017-02-23 at 11.25.42 PM.png
    Christopher Hiller
    @boneskull
    is it possible to get nyc to produce coverage via, say, karma?
    Andy Edwards
    @jedwards1211
    Hi @bcoe, I want to run nyc with mocha --watch and generate fresh coverage reports each time mocha reruns. Do you have any idea off the top of your head how I could do that?
    nyc + mocha is pretty slow to boot up (with ES6 and my code base at least) so I'm trying to streamline my dev process by running it in watch mode.
    Shamus Harkin
    @shamusharkin
    Hi Guys, Im trying to implement Istanbul for code coverage of client side js (we run acceptance tests using codeceptjs).....is there any documentation or repositories that you could point me towards. thanks
    Edwin Perez
    @trigun539

    Hi @bcoe, I want to run nyc with mocha --watch and generate fresh coverage reports each time mocha reruns. Do you have any idea off the top of your head how I could do that?

    Anybody knows how to do this? Also looking for a way to have a watch flag on the coverage

    Jason Kurian
    @JaKXz
    See #310
    Stefan Gojan
    @hoschi
    Hi :)
    Is it possible to transpile and instrument the code once before all tests run?
    nyc instrument throws (silent) errors even when I require babel-core/register
    nyc instrument --instrument=false also doesn't the registered babel
    I have a big AVA test suite and want to precompile as much as possible.
    Mark Wubben
    @novemberborn
    @hoschi you can use the babel plugin to transpile your sources, and then run your tests against that (wrapped with nyc)
    Stefan Gojan
    @hoschi
    hm I thought I tried that already which empty reports, I check it again then
    thanks for the example @novemberborn
    "--source-maps" is interessting, I used -s inline and then nyc acutally instruments the original (source map points to) instead the compiled version, probably thats it already
    Randy Cox
    @randycox-eg
    My client is using istanbul 0.4 in gulp with gulp-istanbul. I'd like to move them to nyc, but there doesn't appear to be a Gulp plugin for nyc. Any ideas?
    Bruno Alexandre
    @balexandre

    Hi guys, I run my tests with mocha using:

    "test": "mocha --reporter progress buildScripts/test-setup.js \"src/**/*.test.js\"",

    but adding nyc to a script like:

    "coverage": "nyc --show-process-tree npm test"

    only adds to coverage the buildScripts/test-setup.js file, not all the others ... what am I missing?

    Bruno Alexandre
    @balexandre
    found a way... adding definition "nyc" in package.json file and set include to the correct files
    Juan Orozco
    @Macrofig
    Hello! We are trying to add NYC to our app. We are using some modules that use a different type of module loading syntax (https://stealjs.com/docs/syntax.steal.html) in their main. But, that modules does have a CJS built shipped in the npm package. How do I tell NYC/Istanbul to use a different main than what is described in the package.json?
    I don't see any configuration options for this here: https://github.com/istanbuljs/nyc/blob/master/README.md
    Benjamin E. Coe
    @bcoe
    @/all hey :wave: I've created a slack for istanbul; I was finding I don't check gitter enough and I'm already in slack all day for work:
    Emanuele Zattin
    @emanuelez
    Hello! I have an issue with nyc on macOS. running nyc somescript.sh works fine on my local machine, but on CI (Jenkins) it produces an empty report. I tried running with --show-process-tree and it gives a whole proper tree on my machine, but it only shows nyc on CI. I'm quite baffled by this. Any hint?
    Alex J Burke
    @alexjeffburke
    hey folks - we've got a server that's instrumented using the Istanbul middleware. The way this works in our projects is we arrange for a JSON version of the coverage output, and we're like to separately run nyc report on it. Unfortunately, trying to do this just led to:
    TypeError: Cannot read property 'start' of undefined
        at ./node_modules/nyc/node_modules/istanbul-reports/lib/lcovonly/index.js:32:43
        at Array.forEach (<anonymous>)
        at LcovOnlyReport.onDetail (./node_modules/nyc/node_modules/istanbul-reports/lib/lcovonly/index.js:30:28)
        at LcovReport.(anonymous function) [as onDetail] (./node_modules/nyc/node_modules/istanbul-reports/lib/lcov/index.js:21:24)
        at Visitor.(anonymous function) [as onDetail] (./node_modules/nyc/node_modules/istanbul-lib-report/lib/tree.js:34:30)
        at ReportNode.Node.visit (./node_modules/nyc/node_modules/istanbul-lib-report/lib/tree.js:123:17)
        at ./node_modules/nyc/node_modules/istanbul-lib-report/lib/tree.js:116:23
        at Array.forEach (<anonymous>)
        at visitChildren (./node_modules/nyc/node_modules/istanbul-lib-report/lib/tree.js:115:32)
        at ReportNode.Node.visit (./node_modules/nyc/node_modules/istanbul-lib-report/lib/tree.js:126:5)
    make: *** [coverage/lcov-report] Error 1
    I am positive I've seen this before, think I even reported it - but I had it in mind this was addressed some time ago. We're using the latest nyc version - if this is familiar to anyone I'd very much appreciate any hints :)
    Hua Lu
    @hualu00
    Hello Group, nyc only generates report for those with 'jsx' extensions, I didn't do anything special about it, why?
    Mike Hingley
    @computamike

    Hi. I’m using NYC, and I have a test question. I have a base class - looks like this :

    class baseProvider {
      /**
       * Prevent direct instantiation of base class.
       */
      constructor () {
        if (new.target === baseProvider) {
          throw new TypeError('Cannot construct baseProvider instances directly - inherrit from this class and add SupportedHost and getoEmbedURL methods.')
        }
      }

    when I’m testing, NYC shows a missed else branch - which I understand - but what I don’t get is that I have tests that instantiate inherrited objects - which would run that else code (do nothing). What can I do?

    I can add / istanbul ignore else / to the If in that constructor - but just wondering if there were a better way
    oldmud0
    @oldmud0
    Hi, I'm using nyc, babel, and coveralls. I notice that coveralls is giving me the wrong coverage for each line. What's going on? https://i.imgur.com/pEX35Es.png
    (I'll take it to Slack)
    Rupam Roy
    @rupamroy
    HI In windows Gitbash , the below command does not run the test and hence no coverage
    $(npm bin)/nyc --report-dir coverage/server $(npm bin)/ts-node --project server/tsconfig.json node_modules/jasmine/bin/jasmine.js 'server/**/!(*index).ts'
     $(npm bin)/nyc --report-dir coverage/server $(npm bin)/ts-node --project server/tsconfig.json node_modules/jasmine/bin/jasmine.js 'server/**/!(*index).ts'                    
    =============================== Coverage summary ===============================
    Statements   : Unknown% ( 0/0 )
    Branches     : Unknown% ( 0/0 )
    Functions    : Unknown% ( 0/0 )
    Lines        : Unknown% ( 0/0 )
    ================================================================================
    The above shows the output
    The ts-node command when run separately works fine
    $ $(npm bin)/ts-node --project server/tsconfig.json node_modules/jasmine/bin/jasmine.js 'server/**/!(*index).ts'
    Started
    ...................................................................................
    
    
    83 specs, 0 failures
    Finished in 0.234 seconds
    Rupam Roy
    @rupamroy
    This does not happen in mac or linux , can someone please help , here are my versions
    $ npm list nyc
    gen-test@0.0.0 C:\dev\gen-test
    `-- nyc@13.0.1
    
    $ npm list ts-node
    gen-test@0.0.0 C:\dev\gen-test
    `-- ts-node@7.0.1
    
    $ npm list jasmine
    gen-test@0.0.0 C:\dev\gen-test
    `-- protractor@5.4.1$ node -v
    
    $ node -v
    v8.11.1
    
    $ npm -v
    5.6.0
    Rupam Roy
    @rupamroy
    Hi , Can anyone help me with my question above
    Sulka Haro
    @sulkaharo
    Frustrating issue: I have a project that uses ES6 module format using the esm package, running tests with mocha and should.js. Tests all run fine as expected. When trying to get code coverage with nyc, the coverage reports ignore files seemingly randomly, where most of the time it looks like only the coverage data from the last test is used (but sometimes all the coverage is reported). I've tried all the permutations of source map generation / instrumentation that I can imagine but nothing seems to work right :( Any pointers where to look?

    Possibly related - if I invoke nyc with 'nyc -i esm', something goes pear shaped:

    TypeError: Cannot convert undefined or null to object
        at __defineGetter__ (<anonymous>)
        at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)

    While according to esmdocs this should work

    jjangga0214
    @jjangga0214
    Hi, can nyc generate specific report(e.g. html) by reading coverage.json (coverage.raw.json)?
    3 replies
    Semih Ural
    @semihural
    Failed to write coverage reports: ERROR: TypeError: Cannot read property 'loc' of undefined STACK: TypeError: Cannot read property 'loc' of undefined at /home/ubuntu/workspace/oneapihub-ui/node_modules/istanbul-reports/lib/lcovonly/index.js:52:27 at Array.forEach (<anonymous>)
    I am able to run unit test in CI but not able to generate coverage report
    Altair J. Fernandes
    @tatosjb
    I have searched on the docs and cant find it.
    Can I generate an html report with nyc from a json file?
    2 replies
    Amin NAIRI
    @aminnairi
    Oddly enough, using the .nycrc.js file and setting some reporters does not work while setting them in the package.json do work well
    1 reply