159

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
};
4
  • 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. Sep 15, 2021 at 18:59
  • Are you using ember-cli-content-security-policy >= 1.1.1?
    – gmanjon
    Nov 10, 2021 at 17:32

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.