0

I am reading through the documentation on karma and istanbul to set up code coverage. I am not sure what I am missing. I included everything that I have used to figure this step out so I apologize if it is long winded.

I tried the to run the start script inside of my npm package but got the error message

Error: Cannot find module 'c:\HA\VSTS\Applications\HA.Web.Main\spec\support\jasmine.json'

-https://karma-runner.github.io/0.8/config/coverage.html

-https://www.npmjs.com/package/istanbul#getting-started

This seems like it should be a fairly straightforward process.

Inside of my karma.conf file I have karma-coverage

 plugins: {
   karma-coverage
]

I set up a coverage reporter object

coverageReporter: {
    // disable code compaction when using instrumenter  * do not want ot minify output
    instrumenterOptions: {
        istanbul: { noCompact: true }
    },
    type: 'html',
    dir: 'coverage/'
},

Inside of the preprocessor I listed the files that I wanted to be covered

preprocessor: [     

 "../Scripts/src/modules/**/*.js": ['coverage']

]

The documenation makes note of the jasmine on windows and identifies the need for a scripts object to use cross platform.

"scripts": {
    "test": "istanbul cover node_modules/jasmine/bin/jasmine.js"
},

I have jasmine in my node modules so that should not be an issue.

I ran to further identify what could be the issue.

istanbul help config

But to be honest I do not now what to look for inside of some of these objects

    verbose: false
instrumentation:
    root: .
    extensions:
        - .js
    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
    include-all-sources: false
    include-pid: false
    es-modules: false
reporting:
    print: summary
    reports:
        - lcov
    dir: ./coverage
    watermarks:
        statements: [50, 80]
        lines: [50, 80]
        functions: [50, 80]
        branches: [50, 80]
    report-config:
        clover: {file: clover.xml}
        cobertura: {file: cobertura-coverage.xml}
        json: {file: coverage-final.json}
        json-summary: {file: coverage-summary.json}
        lcovonly: {file: lcov.info}
        teamcity: {file: null, blockName: Code Coverage Summary}
        text: {file: null, maxCols: 0}
        text-lcov: {file: lcov.info}
        text-summary: {file: null}
hooks:
    hook-run-in-context: false
    post-require-hook: null
    handle-sigint: false
check:
    global:
        statements: 0
        lines: 0
        branches: 0
        functions: 0
        excludes: []
    each:
        statements: 0
        lines: 0
        branches: 0
        functions: 0
        excludes: []
Winnemucca
  • 3,309
  • 11
  • 37
  • 66
  • I have the same error when run istanbul from command line using: `node_modules/istanbul/lib/cli.js cover node_modules/jasmine/bin/jasmine.js` – jcubic Jun 12 '16 at 16:56

1 Answers1

1

You need to call jasmine init to generate that file. If you installed jasmine locally you need to call:

node_modules/jasmine/bin/jasmine.js init
jcubic
  • 61,973
  • 54
  • 229
  • 402