ember-cli-code-coverage mocha showing 0% coverage when there are tests

 I'm using ember-cli-code-coverage with ember-cli-mocha.

When I run COVERAGE=true ember test I'm getting 0% coverage for statements, functions, and lines.
Yet, I have tests that are covering those sections. Any I missing something in my setup?

enter image description here

unit test file:

beforeEach(function() {
    controller = this.subject();
});

it('sets selectedImage to null', function() {
    expect(controller.get('selectedImage')).to.eql(null);
});

describe('setCoverageTest', function() {
    it('sets selectedImage to true', function() {
        expect(controller.get('selectedImage')).to.eql(null);
        controller.setCoverageTest();
        expect(controller.get('selectedImage')).to.be.true;
    });
});

config/coverage.js:

module.exports = {
  excludes: ['*/templates/**/*'],
  useBabelInstrumenter: true
};
  • We use ember-cli-code-coverage@0.4.1 and ember-cli-mocha@0.14.4 with a wide variety of should and chai/expect style assertions. Our config/coverage.js only sets 'parallel' to true. What version are you running? Do you have a public link? I wonder if the excludes is interfering. Are you using pretender or any XHR stubbing by any chance? If so, be sure to exempt Another gotcha: ensure to exempt the '/write-coverage' path. 
    – efx
     Sep 5, 2017 at 23:24 
  • Did you use this.passthrough('/write-coverage'); in your setup? github.com/kategengler/…  Aug 29, 2021 at 13:44
  • We are also using the following properties in our coverage.js: {parallel:false, coverageFolder : ‘pathtofolder’, reporters: [‘lcov’, ‘html’, ‘cobertura’]}. It has been a while since I set this up but try adding these. 
    – Omeri
     Sep 15, 2021 at 18:59 
  • Are you using ember-cli-content-security-policy >= 1.1.1?


Comments

Popular posts from this blog

How do I generate random integers within a specific range in Java?

#1 javascript toturial

Proper use cases for Android UserManager.isUserAGoat()?