Search code examples
istanbuljscoverage

No coverage information was collected, exit without writing coverage information, istanbul coverage


Please does anybody know how i can address this issue ? I have my test:coverage defined as follows.

scripts{
 "test:coverage": "babel-node ./node_modules/.bin/istanbul cover ./node_modules/.bin/_mocha ./src/_utils/__tests__/*.js"
}

and when i run

npm run test:coverage

My mocha runs fine and everything else ok. But my istanbul coverage returns the message in the title at the end. Moreover , my coverage folder remains empty. After reading through online, i was convinced that i had to add .istanbul.yml file . I then proceed and add it below

verbose: false
instrumentation:
    root: ./node_modules/.bin/istanbul
    default-excludes: true
    excludes: []
    embed-source: false
    variable: __coverage__
    compact: true
    preserve-comments: false
    complete-copy: false
    save-baseline: false
    baseline-file: ./coverage/coverage-baseline.json
reporting:
    print: summary
    reports:
        - lcov
    dir: ./coverage
    watermarks:
        statements: [50, 80]
        lines: [50, 80]
        functions: [50, 80]
        branches: [50, 80]
hooks:
    hook-run-in-context: false
    post-require-hook: null

After i run my test:coverage again, the previous istanbul error dispappear. However, The no coverage message in the title still remains and more coverage folder still remains empty. Please where do i go wrong ? Any help would be appreciated.


Solution

  • Please if you encounter similar problem, know that the issue is with the istanbul itself. You need to install babel-istanbul not istanbul . My coverage:text is now like below.

     "test:coverage": "babel-node ./node_modules/.bin/babel-istanbul cover ./node_modules/.bin/_mocha ./src/**/__tests__/*.js",
    

    Also its important to remember and get rid of the .istanbul.yml file . Instead change your src to the babel-istanbul . I removed my .istanbul.yml file and install babel-istanbul . Its working fine.