4

I have an istanbul coverage that i use in my package.json like below.

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

And i jave an .istanbul.yml script like below.

verbose: true
instrumentation:
    extension: .js
    root: ./src
    default-excludes: true
    excludes: ['./src/**/__tests__/**', './src/electron.js']
    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

I am trying to exclude the tests folder and the electron.js files from the coverage. However , the file and the folder are not excluding. Please where do i go wrong and how can i fix this ? Any help would be appreciated.

2 Answers 2

4

Incase if some one is still having this issue. Below is how i solved mine by modifying

instrumentation:
  root: src
  include-all-sources: true
  verbose: true
  excludes: ["**/__tests__/**" ,"./electron.js"]
reporting:
  dir: "coverage"
Sign up to request clarification or add additional context in comments.

1 Comment

Excludes is not working when used in conjunction with include-all-sources set to true. I'm running istanbul cover _mocha from the command line and using "istanbul": "^0.4.5", "mocha": "^3.2.0" in my package.json
1

What worked for us was adding the exclude syntax in our babel config:

plugins: [
    [
      'istanbul',
      {
        exclude: ['**/example/**/**/*'],
      },
    ],
  ],

We clearly hand't read thoroughly the docs! https://github.com/istanbuljs/babel-plugin-istanbul#ignoring-files

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.