{"action":"created","issue":{"url":"https://api.github.com/repos/gotwarlost/istanbul/issues/387","labels_url":"https://api.github.com/repos/gotwarlost/istanbul/issues/387/labels{/name}","comments_url":"https://api.github.com/repos/gotwarlost/istanbul/issues/387/comments","events_url":"https://api.github.com/repos/gotwarlost/istanbul/issues/387/events","html_url":"https://github.com/gotwarlost/istanbul/issues/387","id":88498355,"number":387,"title":"tests passing, but istanbul claims method was not tested at all","user":{"login":"kkragenbrink","id":848667,"avatar_url":"https://avatars.githubusercontent.com/u/848667?v=3","gravatar_id":"","url":"https://api.github.com/users/kkragenbrink","html_url":"https://github.com/kkragenbrink","followers_url":"https://api.github.com/users/kkragenbrink/followers","following_url":"https://api.github.com/users/kkragenbrink/following{/other_user}","gists_url":"https://api.github.com/users/kkragenbrink/gists{/gist_id}","starred_url":"https://api.github.com/users/kkragenbrink/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kkragenbrink/subscriptions","organizations_url":"https://api.github.com/users/kkragenbrink/orgs","repos_url":"https://api.github.com/users/kkragenbrink/repos","events_url":"https://api.github.com/users/kkragenbrink/events{/privacy}","received_events_url":"https://api.github.com/users/kkragenbrink/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":8,"created_at":"2015-06-15T18:05:06Z","updated_at":"2015-06-16T05:36:08Z","closed_at":null,"body":"I am using istanbul with mocha to test my code. Most of my tests are working great to show me proper coverage; however, I have one which adds a method to the util class that istanbul claims has no covergae at all.\r\n\r\nI'm certain that it is fully covered; I can add console messages to prove it, and the actual tests are reporting as passed.  I suspect that the reason istanbul doesn't like to show the coverage is I do not list any arguments in the function declaration, and instead use ```Array.prototype.slice.call(arguments)``` to get the arguments.\r\n\r\nThe code, and test cases, are below.\r\n\r\n```javascript\r\n/**\r\n * Extends an object with any other objects, overwriting variables along the way.\r\n *\r\n * The first argument becomes the 'base'; additional arguments will be used to\r\n * overwrite or extend the base object.  This is very basic inheritence.\r\n *\r\n * @param   {Object...}     arguments   The objects to extend.\r\n * @return  {Object}\r\n */\r\nutil.extend = function () {\r\n    var args                            = Array.prototype.slice.call(arguments);\r\n    var target                          = args.shift();\r\n    target                              = (target !== null && typeof target == 'object') ? target : {};\r\n    var source;\r\n\r\n    while ((source = args.shift()) !== undefined) {\r\n        if (typeof source == 'object' && source !== null && (Object.prototype.toString.call(source) == '[object Object]' || Object.prototype.toString.call(source) == '[object Array]')) {\r\n            for (var i in source) {\r\n                if (source.hasOwnProperty(i)) {\r\n                    if (target !== null && !target.hasOwnProperty(i)) {\r\n                        target[i]       = (Object.prototype.toString.call(source[i]) == '[object Array]') ? [] : {};\r\n                    }\r\n                    target[i]           = util.extend(target[i], source[i]);\r\n                }\r\n            }\r\n        }\r\n        else if (source !== null) {\r\n            target                      = source;\r\n        }\r\n    }\r\n\r\n    return target;\r\n};\r\n```\r\n\r\n```javascript\r\ndescribe('src.Util', function () {\r\n    var util = require('src/Util');\r\n\r\n    describe('.extend', function () {\r\n        it('can extend an object', function () {\r\n            var testObject  = {\"testing1\": \"here1\"};\r\n\r\n            util.extend(testObject, {\"testing2\": \"here2\"});\r\n            util.extend(testObject, {\"testing3\": \"here3\"}, {\"testing4\": \"here4\"});\r\n            util.extend(testObject, {\"testing5\": {\"testing6\": \"here6\"}});\r\n\r\n            assert.strictEqual(testObject.testing1, 'here1');\r\n            assert.strictEqual(testObject.testing2, 'here2');\r\n            assert.strictEqual(testObject.testing3, 'here3');\r\n            assert.strictEqual(testObject.testing4, 'here4');\r\n            assert.strictEqual(testObject.testing5.testing6, 'here6');\r\n        });\r\n\r\n        it('dereferences when extrending', function () {\r\n            var test1 = ['a','b','c'];\r\n\r\n            var test2 = util.extend([], test1);\r\n            test2.shift();\r\n\r\n            assert.deepEqual(test1, ['a', 'b', 'c']);\r\n            assert.deepEqual(test2, ['b', 'c']);\r\n        });\r\n\r\n        it('can extend falsey values', function () {\r\n            var testObject = {value1: false};\r\n\r\n            util.extend(testObject, {value2: false});\r\n            assert.deepEqual(testObject, {value1: false, value2: false});\r\n        });\r\n\r\n        it('only extends objects', function () {\r\n            var testObject2  = {\"testing1\": \"here1\"};\r\n            var f = {\"testing1\": \"here1\"};\r\n            util.extend(testObject2, true);\r\n            assert.deepEqual(f, testObject2);\r\n        });\r\n    });\r\n});\r\n```"},"comment":{"url":"https://api.github.com/repos/gotwarlost/istanbul/issues/comments/112298247","html_url":"https://github.com/gotwarlost/istanbul/issues/387#issuecomment-112298247","issue_url":"https://api.github.com/repos/gotwarlost/istanbul/issues/387","id":112298247,"user":{"login":"gotwarlost","id":1056819,"avatar_url":"https://avatars.githubusercontent.com/u/1056819?v=3","gravatar_id":"","url":"https://api.github.com/users/gotwarlost","html_url":"https://github.com/gotwarlost","followers_url":"https://api.github.com/users/gotwarlost/followers","following_url":"https://api.github.com/users/gotwarlost/following{/other_user}","gists_url":"https://api.github.com/users/gotwarlost/gists{/gist_id}","starred_url":"https://api.github.com/users/gotwarlost/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gotwarlost/subscriptions","organizations_url":"https://api.github.com/users/gotwarlost/orgs","repos_url":"https://api.github.com/users/gotwarlost/repos","events_url":"https://api.github.com/users/gotwarlost/events{/privacy}","received_events_url":"https://api.github.com/users/gotwarlost/received_events","type":"User","site_admin":false},"created_at":"2015-06-16T05:36:08Z","updated_at":"2015-06-16T05:36:08Z","body":"Given the data where one method gets covered correctly but another method in the same file doesn't, it may be that some other file else is *also* overriding `util.extend`. So, sequence is:\r\n\r\n* `require Util.js` // istanbul adds instrumentations\r\n* `require some-other-file` // overwrites util.extend and sets it to something else\r\n* `run tests - util.extend is not covered\r\n\r\nThis may also be why things work when you pull it out and test it separately."}}