Giter Club home page Giter Club logo

learn-istanbul's Issues

How to ignore files (e.g: libraries) from coverage using a .istanbul.yml file?

Sometimes you want to ignore a specific file or even a folder from being checked by Istanbul
e.g you include a 3rd party library or code in your project (instead of putting it on a CDN)

You can define a list of excludes files in a .istanbul.yml at the root of your project/repo.

Its not an especially well-documented feature... There's only one reference to .istanbul.yml in the entire Istanbul project, see: https://github.com/gotwarlost/istanbul/search?l=markdown&q=.istanbul.yml&utf8=%E2%9C%93

There are examples on the StackOverflows if you search for them. e.g: http://stackoverflow.com/a/34685175/1148249

instrumentation:
    root: .
    extensions:
        - .js
    default-excludes: true
    excludes: ['**/tinymce/**', '**/lib/**', '**/tools/**', '**/build/**']
    include-all-sources: true

a more detailed sample file: https://github.com/vesln/todo/blob/master/.istanbul.yml

@nikhilaravi needed this today in our project, it reminded me we should add it to the readme.

Unable to run whole project

image
/usr/bin/istanbul --include-all-sources cover --recursive ./src/talos/wwwroot/panojs/pyramid_Zoomify.js
I am unable to run whole project
can anyone guide me ?
The above image only for one single file

Check in

Hi,

I am not sure if this was intended in the first place or a typo. I was learning from your article and the first time I ran code coverage on mischief.js, it had a 100% coverage. After scratching my head for sometime, I realized it's doing what the test asked it to do. I had to update the 20000 to number < 10000 to have the right output.

console.log("\nExpect Account1 Opening Balance "+getAccountBalance(account1) +" === 0 \u2713 ");
creditAccount(account1, 2000, 'Add Funds');
transferMoney(account1,account2, 100, 'Give money to friend');
transferMoney(account2,account1, 10, 'Transfer back 10');

Advice needed :-) on implementation of Codecov without key on Travis

I'm trying to use Codecov on Travis without using the key as you told me it can be done without and so in the name of efficiency I want to learn how it's done!
My .travis.yml and package.json look like yours:
https://github.com/Cleop/triumph-website/blob/master/.travis.yml#L3-L6
https://github.com/Cleop/triumph-website/blob/master/package.json#L10

And I'm registered on Codecov and have selected the repo.

However I'm not getting any data on Codecov when I merge PR or on the badge on my README.

Any advice would be greatly appreciated ๐Ÿ˜„ Thank you!

(ES6) Missing description about branches originated by default value for function parameters

I'm using istanbul 0.4.5 (with istanbul-lib-coverage 1.2.0 and istanbul-lib-instrument 1.10.1) to check coverage of my jasmine unit tests over my ES6 source, and I found a branches count which is not mentioned in your document.

If my function has a default value for input parameter, like this (this is a class used to create an AngularJS service):

class UserDataService {
    getClientData() {
        return this.client;
    }
    setClientData(obj = { foo: 'bar' }) {
        this.client = obj;
    }
}
export default UserDataService;

Notice the default value for setClientData parameter obj.

If my test suite is:

import moduleUnderTesting from './userData';

describe('Service: UserDataService', () => {
    let service;

    beforeEach(() => {
        angular.mock.module(moduleUnderTesting);
    });

    beforeEach(inject((_UserDataService_) => {
        service = _UserDataService_;
    }));

    describe('method setClientData and getClientData', () => {
        it('should set/get clientData correctly', () => {
            const cData = { one: 1, two: 2 };
            service.setClientData(cData);
            expect(service.getClientData()).toBe(cData);
        });
    });
});

The test run reports 1 branch not covered:

Branch not covered

While, if I add a test case that makes setClientData use the default value for obj parameter, like this:

import moduleUnderTesting from './userData';

describe('Service: UserDataService', () => {
    let service;

    beforeEach(() => {
        angular.mock.module(moduleUnderTesting);
    });

    beforeEach(inject((_UserDataService_) => {
        service = _UserDataService_;
    }));

    describe('method setClientData and getClientData', () => {
        it('should set/get clientData correctly', () => {
            const cData = { one: 1, two: 2 };
            service.setClientData(cData);
            expect(service.getClientData()).toBe(cData);
        });

        it('should set/get clientData correctly using default value', () => {
            service.setClientData();
            expect(service.getClientData()).toEqual({ foo: 'bar' });
        });
    });
});

Test run reports full coverage:

Branch covered

This is an issue of istanbul itself, because the coverage should show what's the missing branch; anyway, I'm reporting it here as well in order for it to be pointed out in your document.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.