codeclimate / test-reporter

Code Climate Test Reporter
MIT License
156 stars 76 forks source link

ES6 Javascript Project + Travis not generating code coverage. #326

Closed ecsunder15 closed 6 years ago

ecsunder15 commented 6 years ago

I currently have a project that is an ES6 javascript project that has local coverage with babel-plugin-istanbul and karma-coverage working and generating an lcov format report on the top level directory. The npm test command generates the lcov coverage report. After running the build on Travis with exit code 0, I get the error, "could not find any viable formatter. available formatters: simplecov, lcov, coverage.py, clover, gocov, gcov, cobertura, jacoco". I have set up my travis.yml as follows:

env:
  global:
  - CXX=g++-4.8
  - CC_TEST_REPORTER_ID=<my-Repo-ID>
before_script:
- npm prune
- npm install
- bundle install
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
- chmod +x ./cc-test-reporter
- ./cc-test-reporter before-build
script: npm test
after_script:
  - ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT

Here are my karma.config.js reporters:

reporters: ['progress', 'coverage'],
    coverageReporter: {
      type: 'lcov',
      dir: '.',
      subdir: '.'
    },

Is there a reason as to why the CC reporter cannot find my files in Travis? I have followed the docs to get to this point and there seem to be few examples of Javascript projects using the CC code coverage tool.

ecsunder15 commented 6 years ago

I ran the build in -debug this morning, and found that there was a section of my code that had specific reporters for a travis environment. Added the coverage/ directory there and the CC data was sent over fine. In the future, I would note that if there are any travis-specific instructions or configs outside of travis.yml, they need to include the coverage reporter.

if (process.env.TRAVIS) {
    config.set({
      reporters: ['jasmine-diff', 'spec', 'coverage'] ,
      coverageReporter: {
        type: 'lcov',
        dir: 'coverage/',
        subdir: '.'
      },
      colors: true,
    });
  }