From 51eedbc44a44ff6f6fbe5a06e457e46c913e4607 Mon Sep 17 00:00:00 2001 From: Robert Jackson Date: Thu, 30 Jun 2016 08:55:50 -0400 Subject: [PATCH 01/39] Add `includePolyfill` to removed babel options. --- lib/coverage-instrumenter.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/coverage-instrumenter.js b/lib/coverage-instrumenter.js index 873c26a3..99748984 100644 --- a/lib/coverage-instrumenter.js +++ b/lib/coverage-instrumenter.js @@ -62,7 +62,8 @@ function CoverageInstrumenter(inputNode, options) { // simply remove them from the babel config [ 'compileModules', - 'resolveModuleSource' + 'resolveModuleSource', + 'includePolyfill' ].forEach(function(key) { delete this._babelOptions[key]; }.bind(this)); From 62b73abd94f476f3fa011b55909e34dda76449e6 Mon Sep 17 00:00:00 2001 From: Robert Jackson Date: Thu, 30 Jun 2016 09:01:53 -0400 Subject: [PATCH 02/39] Released v0.2.2 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index e4543a16..ccb92007 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ember-cli-code-coverage", - "version": "0.2.1", + "version": "0.2.2", "description": "Code coverage for ember projects using Istanbul", "directories": { "doc": "doc", From dc9c95f2f0a8c80488e8e198cc7f01fbb4040a24 Mon Sep 17 00:00:00 2001 From: Katie Gengler Date: Mon, 8 Aug 2016 15:33:38 -0400 Subject: [PATCH 03/39] Use chrome, not phantom for tests - Make errors more helpful when tests error in the future --- .travis.yml | 12 +++++++++++- test/helpers/run-command.js | 4 ++-- testem.js | 3 +-- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index dac66441..03989290 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,7 +6,15 @@ node_js: - "4.2" - "5" -sudo: false +dist: trusty +sudo: required + +addons: + apt: + sources: + - google-chrome + packages: + - google-chrome-stable cache: directories: @@ -24,6 +32,8 @@ matrix: env: NPM_SCRIPT=lint before_install: + - "export DISPLAY=:99.0" + - "sh -e /etc/init.d/xvfb start" - "npm config set spin false" - "npm install -g npm@^2" diff --git a/test/helpers/run-command.js b/test/helpers/run-command.js index be326a2b..48066c9a 100644 --- a/test/helpers/run-command.js +++ b/test/helpers/run-command.js @@ -6,7 +6,7 @@ var spawn = require('child_process').spawn; module.exports = function runCommand(command, args, opts) { opts = opts || {}; - opts.stdio = opts.stdio || 'ignore'; + opts.stdio = opts.stdio || 'inherit'; var newENV = {}; var item, envOption; @@ -24,7 +24,7 @@ module.exports = function runCommand(command, args, opts) { var p = spawn(command, args, opts); p.on('close', function(code) { if (code !== 0) { - reject(code); + reject(new Error('Command ' + command + ' ' + args.join(' ') + ' exited ' + code)); } else { resolve(); } diff --git a/testem.js b/testem.js index f37e0a49..2c1382b2 100644 --- a/testem.js +++ b/testem.js @@ -7,10 +7,9 @@ module.exports = { "test_page": "tests/index.html?hidepassed", "disable_watching": true, "launch_in_ci": [ - "PhantomJS" + "Chrome" ], "launch_in_dev": [ - "PhantomJS", "Chrome" ] }; From f2ba0e8091daedc20e4d196138fbf9f841f8eb3f Mon Sep 17 00:00:00 2001 From: Robert Jackson Date: Wed, 3 Aug 2016 17:21:58 -0400 Subject: [PATCH 04/39] Avoid requiring jQuery for sending the coverage report back. --- lib/templates/test-body-footer.html | 56 ++++++++++++++--------------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/lib/templates/test-body-footer.html b/lib/templates/test-body-footer.html index 580bbe8b..573a1ac6 100644 --- a/lib/templates/test-body-footer.html +++ b/lib/templates/test-body-footer.html @@ -3,37 +3,37 @@ var coverageData = window.__coverage__; var data = JSON.stringify(coverageData || {}); - $.ajax({ - type: 'POST', - async: false, - url: '/write-coverage', - datatype: 'json', - contentType:'application/json; charset=utf-8', - data: data, - error: function(jqXHR, textStatus, errorThrown ) { - throw errorThrown; - }, - success: function(data) { - if (!data || !data.total) { - return; - } + var request = new XMLHttpRequest(); + request.open('POST', '/write-coverage', true); + request.setRequestHeader('Content-Type', 'application/json; charset=utf-8'); + request.send(data); + request.responseType = 'json'; - var results = ['Lines', 'Branches', 'Functions', 'Statements'] - .filter(function (name) { - return data.total[name.toLowerCase()] - }) - .map(function (name) { - return name + ' ' + data.total[name.toLowerCase()].pct + '%' - }) + request.onload = function() { + var data = this.response; - $('body').append('
' + results.join(' | ') + '
'); - }, - complete: function() { - if (callback) { - callback(); - } + if (!data || !data.total) { + return; } - }); + + var results = ['Lines', 'Branches', 'Functions', 'Statements'] + .filter(function (name) { + return data.total[name.toLowerCase()] + }) + .map(function (name) { + return name + ' ' + data.total[name.toLowerCase()].pct + '%' + }); + + var resultsText = document.createTextNode(results.join(' | ')); + var element = document.createElement('div'); + element.style = 'background-color: white; color: black; border: 2px solid black; padding: 1em;position: fixed; left: 15px; bottom: 15px'; + element.appendChild(resultsText); + document.body.appendChild(element); + + if (callback) { + callback(); + } + }; } if (typeof Testem !== "undefined" && Testem.afterTests) { From 7927ba6f48f39e90d0a2aa46341caa3ea4496b0c Mon Sep 17 00:00:00 2001 From: Katie Gengler Date: Thu, 11 Aug 2016 11:47:06 -0400 Subject: [PATCH 05/39] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b70ba69c..0b7215a8 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ Code coverage using [Istanbul](https://github.com/gotwarlost/istanbul) for Ember ## Requirements * If using Mocha, Testem `>= 1.6.0` for which you need ember-cli `> 2.4.3` * If using Mirage you need `ember-cli-mirage >= 0.1.13` -* If using Pretender you need `pretender >= 0.11.0` +* If using Pretender (even as a dependency of Mirage) you need `pretender >= 0.11.0` ## Installation From 9b6bf3403c7bdf538889b59ba04ff396afd381cf Mon Sep 17 00:00:00 2001 From: Katie Gengler Date: Thu, 11 Aug 2016 11:49:06 -0400 Subject: [PATCH 06/39] Update README.md --- README.md | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 0b7215a8..224e05b4 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ For example: ## Configuration -Configuration is optional. It should be put in a file at `config/coverage.js`. +Configuration is optional. It should be put in a file at `config/coverage.js`. #### Options @@ -36,6 +36,13 @@ Configuration is optional. It should be put in a file at `config/coverage.js`. - `useBabelInstrumenter`: Defaults to `false`. Whether or not to use Babel instrumenter instead of default instrumenter. The Babel instrumenter is useful when you are using features of ESNext as it uses your Babel configuration defined in `ember-cli-build.js`. +#### Example +```js + module.exports = { + coverageEnvVar: 'COV' + } +``` + ## Using when intercepting all ajax requests in tests Aka when using ember-cli-mirage or Pretender. You may require a version of Pretender that includes [this fix](https://github.com/pretenderjs/pretender/pull/130). From 031b969ae2c94d35773892586c4d3bd400a2e2a0 Mon Sep 17 00:00:00 2001 From: Eric White Date: Thu, 18 Aug 2016 15:31:23 -0400 Subject: [PATCH 07/39] Cover untested files WIP --- index.js | 2 +- lib/attach-middleware.js | 5 +++++ lib/templates/test-body-footer.html | 23 +++++++++++++++++++++++ 3 files changed, 29 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 698661f1..bfae7815 100644 --- a/index.js +++ b/index.js @@ -90,7 +90,7 @@ module.exports = { */ testemMiddleware: function(app) { if (!this._isCoverageEnabled()) { return; } - attachMiddleware(app, { root: this.project.root, ui: this.ui }); + attachMiddleware(app, { root: this.project.root, ui: this.ui, appName: this.parent.pkg.name }); }, // Custom Methods diff --git a/lib/attach-middleware.js b/lib/attach-middleware.js index bb612c74..d0d7a102 100644 --- a/lib/attach-middleware.js +++ b/lib/attach-middleware.js @@ -34,4 +34,9 @@ module.exports = function(app, options) { }); }, logError); + + app.get('/get-module-name', + function(req, res) { + res.send({ appName: options.appName }) + }) }; diff --git a/lib/templates/test-body-footer.html b/lib/templates/test-body-footer.html index 580bbe8b..781f21e8 100644 --- a/lib/templates/test-body-footer.html +++ b/lib/templates/test-body-footer.html @@ -36,8 +36,31 @@ }); } + function getModuleName (){ + return jQuery.ajax({ + url: '/get-module-name', + async: false + }).responseJSON // TODO: async after POC + } + if (typeof Testem !== "undefined" && Testem.afterTests) { Testem.afterTests(function(config, data, callback) { + var seen = {} + var appName = getModuleName().appName + for (var moduleName in requirejs.entries) { + if (typeof(seen[moduleName]) === 'undefined') { + if (moduleName.indexOf(appName) > -1){ + try { + console.warn('requiring unseen module: ' + moduleName) + require(moduleName); + seen[moduleName] = true; + + } catch (err) { + console.log(err); + } + } + } + } sendCoverage(callback); }); } else if (typeof QUnit !== "undefined") { From f4100fef2f1fe8a5bf914b3295dfc902b35661bc Mon Sep 17 00:00:00 2001 From: Eric White Date: Thu, 18 Aug 2016 15:38:44 -0400 Subject: [PATCH 08/39] Split moduleName into parts and check so we don't accidently pick up some random module --- lib/templates/test-body-footer.html | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/templates/test-body-footer.html b/lib/templates/test-body-footer.html index 781f21e8..09b3c7d6 100644 --- a/lib/templates/test-body-footer.html +++ b/lib/templates/test-body-footer.html @@ -49,16 +49,16 @@ var appName = getModuleName().appName for (var moduleName in requirejs.entries) { if (typeof(seen[moduleName]) === 'undefined') { - if (moduleName.indexOf(appName) > -1){ + var parts = moduleName.split('/') try { - console.warn('requiring unseen module: ' + moduleName) - require(moduleName); - seen[moduleName] = true; - + if (parts.length >= 1 && parts[0] === appName || parts.length >= 2 && parts[0] === 'dummy' && parts[1] === appName){ + console.warn('requiring unseen module: ' + moduleName) + require(moduleName); + seen[moduleName] = true; + } } catch (err) { console.log(err); } - } } } sendCoverage(callback); From 1ebdf100b0a6a38a3e32e29798ecde43d9875f34 Mon Sep 17 00:00:00 2001 From: Eric White Date: Thu, 18 Aug 2016 17:11:56 -0400 Subject: [PATCH 09/39] Should exclude --- index.js | 2 +- lib/attach-middleware.js | 20 +++++++++++++++++++- lib/templates/test-body-footer.html | 19 +++++++++++++++---- package.json | 1 + 4 files changed, 36 insertions(+), 6 deletions(-) diff --git a/index.js b/index.js index bfae7815..fbfd7083 100644 --- a/index.js +++ b/index.js @@ -90,7 +90,7 @@ module.exports = { */ testemMiddleware: function(app) { if (!this._isCoverageEnabled()) { return; } - attachMiddleware(app, { root: this.project.root, ui: this.ui, appName: this.parent.pkg.name }); + attachMiddleware(app, { root: this.project.root, ui: this.ui, appName: this.parent.pkg.name, excludes: this._getConfig().excludes || [] }); }, // Custom Methods diff --git a/lib/attach-middleware.js b/lib/attach-middleware.js index d0d7a102..0716fd86 100644 --- a/lib/attach-middleware.js +++ b/lib/attach-middleware.js @@ -5,13 +5,20 @@ var Istanbul = require('istanbul'); var config = require('./config'); var path = require('path'); var fs = require('fs-extra'); - +var minimatch = require('minimatch') function logError(err, req, res, next) { console.error(err.stack); next(err); } module.exports = function(app, options) { + app.use(bodyParser.urlencoded({ + limit: '50mb', + extended: true + })) + app.use(bodyParser.json({ + limit: '50mb' + })) app.post('/write-coverage', bodyParser.json({ limit: '50mb' }), function(req, res) { @@ -39,4 +46,15 @@ module.exports = function(app, options) { function(req, res) { res.send({ appName: options.appName }) }) + + app.post('/should-exclude', + function(req, res) { + for (var i=0; i= 1 && parts[0] === appName || parts.length >= 2 && parts[0] === 'dummy' && parts[1] === appName){ - console.warn('requiring unseen module: ' + moduleName) - require(moduleName); - seen[moduleName] = true; + if (!shouldExclude(moduleName).result){ + console.warn('requiring unseen module: ' + moduleName) + require(moduleName); + } + seen[moduleName] = true; } } catch (err) { console.log(err); diff --git a/package.json b/package.json index e4543a16..105a2270 100644 --- a/package.json +++ b/package.json @@ -64,6 +64,7 @@ "extend": "^3.0.0", "fs-extra": "^0.26.7", "istanbul": "^0.4.3", + "minimatch": "^3.0.3", "source-map": "0.5.6" }, "ember-addon": { From f3eb8c03f06e6458110bcdcc5e4b3191893d15db Mon Sep 17 00:00:00 2001 From: Eric White Date: Fri, 19 Aug 2016 09:51:44 -0400 Subject: [PATCH 10/39] No app.use --- lib/attach-middleware.js | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/lib/attach-middleware.js b/lib/attach-middleware.js index 0716fd86..df2f31bc 100644 --- a/lib/attach-middleware.js +++ b/lib/attach-middleware.js @@ -12,13 +12,6 @@ function logError(err, req, res, next) { } module.exports = function(app, options) { - app.use(bodyParser.urlencoded({ - limit: '50mb', - extended: true - })) - app.use(bodyParser.json({ - limit: '50mb' - })) app.post('/write-coverage', bodyParser.json({ limit: '50mb' }), function(req, res) { @@ -47,7 +40,12 @@ module.exports = function(app, options) { res.send({ appName: options.appName }) }) - app.post('/should-exclude', + app.post('/should-exclude',bodyParser.urlencoded({ + limit: '50mb', + extended: true + }),bodyParser.json({ + limit: '50mb' + }), function(req, res) { for (var i=0; i Date: Fri, 19 Aug 2016 09:53:15 -0400 Subject: [PATCH 11/39] jscs fixes --- lib/attach-middleware.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/attach-middleware.js b/lib/attach-middleware.js index df2f31bc..6fa1e1d9 100644 --- a/lib/attach-middleware.js +++ b/lib/attach-middleware.js @@ -47,8 +47,8 @@ module.exports = function(app, options) { limit: '50mb' }), function(req, res) { - for (var i=0; i Date: Fri, 19 Aug 2016 10:03:05 -0400 Subject: [PATCH 12/39] Fix test --- test/unit/index-test.js | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/test/unit/index-test.js b/test/unit/index-test.js index e81319fa..8da13175 100644 --- a/test/unit/index-test.js +++ b/test/unit/index-test.js @@ -64,12 +64,18 @@ describe('index.js', function() { beforeEach(function() { app = { - post: sinon.spy() + post: sinon.spy(), + get: sinon.spy() }; Index.project = { root: '/path/to/foo-bar' }; + Index.parent = { + pkg: { + name: 'foo-bar' + } + } }); describe('when coverage is enabled', function() { @@ -78,8 +84,12 @@ describe('index.js', function() { Index.testemMiddleware(app); }); - it('adds POST endpoint to app', function() { - expect(app.post.callCount).to.equal(1); + it('adds POST endpoints to app', function() { + expect(app.post.callCount).to.equal(2); + }); + + it('adds GET endpoint to app', function() { + expect(app.get.callCount).to.equal(1); }); }); @@ -92,6 +102,9 @@ describe('index.js', function() { it('does not add POST endpoint to app', function() { expect(app.post.callCount).to.equal(0); }); + it('does not GET endpoint to app', function() { + expect(app.get.callCount).to.equal(0); + }); }); }); From 9abc062de0e59aea3ec04416b6acb7d506446474 Mon Sep 17 00:00:00 2001 From: Eric White Date: Mon, 22 Aug 2016 11:02:44 -0400 Subject: [PATCH 13/39] Flip so there is only one POST request rather than multiple. --- lib/attach-middleware.js | 38 +++++++++++++++++++++++------ lib/templates/test-body-footer.html | 31 +++++++++-------------- 2 files changed, 42 insertions(+), 27 deletions(-) diff --git a/lib/attach-middleware.js b/lib/attach-middleware.js index 6fa1e1d9..fd3a91f9 100644 --- a/lib/attach-middleware.js +++ b/lib/attach-middleware.js @@ -40,19 +40,41 @@ module.exports = function(app, options) { res.send({ appName: options.appName }) }) - app.post('/should-exclude',bodyParser.urlencoded({ + + function shouldExclude(moduleName, excludes){ + for (var i = 0; i < excludes.length; i++) { + if (minimatch(moduleName, excludes[i])) { + return true + } + } + return false + } + app.post('/filter-entries',bodyParser.urlencoded({ limit: '50mb', - extended: true + extended: false, + parameterLimit: 10000 }),bodyParser.json({ limit: '50mb' }), function(req, res) { - for (var i = 0; i < options.excludes.length; i++) { - if (minimatch(req.body.moduleName, options.excludes[i])) { - res.send({result: true}) - return + var entries = req.body['entries[]'] || req.body.entries + debugger + var seen = {} + var appName = options.appName + var filteredEntries = entries.filter(function (entry){ + var result = false + if (typeof(seen[entry]) === 'undefined') { + var parts = entry.split('/') + if (parts.length >= 1 && parts[0] === appName || parts.length >= 2 && parts[0] === 'dummy' && parts[1] === appName){ + if (!shouldExclude(entry, options.excludes)){ + result = true + } + } + seen[entry] = true; + return result } - } - res.send({result: false}) + return result + }) + res.send({entries: filteredEntries}) }) }; diff --git a/lib/templates/test-body-footer.html b/lib/templates/test-body-footer.html index c579fee4..1f9738d5 100644 --- a/lib/templates/test-body-footer.html +++ b/lib/templates/test-body-footer.html @@ -42,34 +42,27 @@ async: false }).responseJSON // TODO: async after POC } - function shouldExclude(moduleName){ + function filterEntries(entries){ return jQuery.ajax({ type: 'POST', - url: '/should-exclude', + url: '/filter-entries', async: false, data: { - moduleName: moduleName + entries: entries } }).responseJSON } if (typeof Testem !== "undefined" && Testem.afterTests) { Testem.afterTests(function(config, data, callback) { - var seen = {} - var appName = getModuleName().appName - for (var moduleName in requirejs.entries) { - if (typeof(seen[moduleName]) === 'undefined') { - var parts = moduleName.split('/') - try { - if (parts.length >= 1 && parts[0] === appName || parts.length >= 2 && parts[0] === 'dummy' && parts[1] === appName){ - if (!shouldExclude(moduleName).result){ - console.warn('requiring unseen module: ' + moduleName) - require(moduleName); - } - seen[moduleName] = true; - } - } catch (err) { - console.log(err); - } + console.log('filtering entries') + var entries = filterEntries(Object.keys(requirejs.entries)).entries + console.log(entries) + for (var entry in entries){ + console.warn('requiring unseen module: ' + entries[entry]) + try { + require(entries[entry]) + } catch (err){ + console.error(err) } } sendCoverage(callback); From b0e3f48ce79805dfab14c58990335139bab976ee Mon Sep 17 00:00:00 2001 From: Eric White Date: Mon, 22 Aug 2016 11:16:50 -0400 Subject: [PATCH 14/39] Fix tests and jscs --- lib/attach-middleware.js | 16 +++++----------- test/unit/index-test.js | 4 ---- 2 files changed, 5 insertions(+), 15 deletions(-) diff --git a/lib/attach-middleware.js b/lib/attach-middleware.js index fd3a91f9..25140cc6 100644 --- a/lib/attach-middleware.js +++ b/lib/attach-middleware.js @@ -35,13 +35,7 @@ module.exports = function(app, options) { }, logError); - app.get('/get-module-name', - function(req, res) { - res.send({ appName: options.appName }) - }) - - - function shouldExclude(moduleName, excludes){ + function shouldExclude(moduleName, excludes) { for (var i = 0; i < excludes.length; i++) { if (minimatch(moduleName, excludes[i])) { return true @@ -61,12 +55,12 @@ module.exports = function(app, options) { debugger var seen = {} var appName = options.appName - var filteredEntries = entries.filter(function (entry){ + var filteredEntries = entries.filter(function(entry) { var result = false - if (typeof(seen[entry]) === 'undefined') { + if (typeof (seen[entry]) === 'undefined') { var parts = entry.split('/') - if (parts.length >= 1 && parts[0] === appName || parts.length >= 2 && parts[0] === 'dummy' && parts[1] === appName){ - if (!shouldExclude(entry, options.excludes)){ + if (parts.length >= 1 && parts[0] === appName || parts.length >= 2 && parts[0] === 'dummy' && parts[1] === appName) { + if (!shouldExclude(entry, options.excludes)) { result = true } } diff --git a/test/unit/index-test.js b/test/unit/index-test.js index 8da13175..527fe315 100644 --- a/test/unit/index-test.js +++ b/test/unit/index-test.js @@ -87,10 +87,6 @@ describe('index.js', function() { it('adds POST endpoints to app', function() { expect(app.post.callCount).to.equal(2); }); - - it('adds GET endpoint to app', function() { - expect(app.get.callCount).to.equal(1); - }); }); describe('when coverage is not enabled', function() { From c73da3a4f178cc44bacd5ba88c86c063ea0f12c8 Mon Sep 17 00:00:00 2001 From: Robert Jackson Date: Wed, 14 Sep 2016 11:12:27 -0400 Subject: [PATCH 15/39] 0.3.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index ccb92007..70cc5165 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ember-cli-code-coverage", - "version": "0.2.2", + "version": "0.3.0", "description": "Code coverage for ember projects using Istanbul", "directories": { "doc": "doc", From 4e64a93b8c7d97f37f7c1dacd11d6318ab55910d Mon Sep 17 00:00:00 2001 From: Robert Jackson Date: Wed, 14 Sep 2016 11:14:43 -0400 Subject: [PATCH 16/39] Update CHANGELOG.md --- CHANGELOG.md | 83 ++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 77 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8393ff7b..174b0300 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +1,79 @@ -- 0.1.2 -Bugfix: Fix config to override defaults (thanks @rwjblue) +# Change Log -- 0.1.1 -Bugfix: For QUnit users: support for `/tests` and older ember-cli (`< 2.4.3`) versions +## [v0.3.0](https://github.com/kategengler/ember-cli-code-coverage/tree/v0.3.0) (2016-09-14) +[Full Changelog](https://github.com/kategengler/ember-cli-code-coverage/compare/v0.2.2...v0.3.0) -- 0.1.0 -Initial release. +**Closed issues:** + +- does not work with addons [\#26](https://github.com/kategengler/ember-cli-code-coverage/issues/26) +- Does not appear to work with decorators [\#25](https://github.com/kategengler/ember-cli-code-coverage/issues/25) +- No Coverage generated got following error [\#21](https://github.com/kategengler/ember-cli-code-coverage/issues/21) +- Support Addon Coverage [\#14](https://github.com/kategengler/ember-cli-code-coverage/issues/14) + +**Merged pull requests:** + +- Support Addon Coverage [\#31](https://github.com/kategengler/ember-cli-code-coverage/pull/31) ([rwjblue](https://github.com/rwjblue)) +- Processed addon js files [\#30](https://github.com/kategengler/ember-cli-code-coverage/pull/30) ([EWhite613](https://github.com/EWhite613)) +- Avoid requiring jQuery for sending the coverage report back. [\#24](https://github.com/kategengler/ember-cli-code-coverage/pull/24) ([rwjblue](https://github.com/rwjblue)) +- Try catch around instrumenter. So it spits out a clearer error [\#22](https://github.com/kategengler/ember-cli-code-coverage/pull/22) ([EWhite613](https://github.com/EWhite613)) + +## [v0.2.2](https://github.com/kategengler/ember-cli-code-coverage/tree/v0.2.2) (2016-06-30) +[Full Changelog](https://github.com/kategengler/ember-cli-code-coverage/compare/v0.2.1...v0.2.2) + +**Closed issues:** + +- Enabling useBabelInstrumenter results in "Unknown option: direct.includePolyfill" error [\#18](https://github.com/kategengler/ember-cli-code-coverage/issues/18) +- Should .hbs files be taken into account? [\#17](https://github.com/kategengler/ember-cli-code-coverage/issues/17) + +**Merged pull requests:** + +- Add `includePolyfill` to removed babel options. [\#19](https://github.com/kategengler/ember-cli-code-coverage/pull/19) ([rwjblue](https://github.com/rwjblue)) + +## [v0.2.1](https://github.com/kategengler/ember-cli-code-coverage/tree/v0.2.1) (2016-06-22) +[Full Changelog](https://github.com/kategengler/ember-cli-code-coverage/compare/v0.2.0...v0.2.1) + +**Closed issues:** + +- Coverage is against transpiled ES5 Code [\#12](https://github.com/kategengler/ember-cli-code-coverage/issues/12) + +**Merged pull requests:** + +- Update ember-cli-release to allow easier releasing. [\#16](https://github.com/kategengler/ember-cli-code-coverage/pull/16) ([rwjblue](https://github.com/rwjblue)) +- Report Correct Line Numbers for esnext [\#15](https://github.com/kategengler/ember-cli-code-coverage/pull/15) ([sandersky](https://github.com/sandersky)) + +## [v0.2.0](https://github.com/kategengler/ember-cli-code-coverage/tree/v0.2.0) (2016-06-21) +[Full Changelog](https://github.com/kategengler/ember-cli-code-coverage/compare/v0.1.2...v0.2.0) + +**Closed issues:** + +- paths in "lcov.info" don't relate to project setup [\#8](https://github.com/kategengler/ember-cli-code-coverage/issues/8) +- files from addons bleed into coverage results [\#7](https://github.com/kategengler/ember-cli-code-coverage/issues/7) +- Change config file name? [\#4](https://github.com/kategengler/ember-cli-code-coverage/issues/4) + +**Merged pull requests:** + +- Filter out files from addons, fix file paths, and rename config file [\#11](https://github.com/kategengler/ember-cli-code-coverage/pull/11) ([sandersky](https://github.com/sandersky)) +- Add ember-cli-mirage min version to README.md [\#3](https://github.com/kategengler/ember-cli-code-coverage/pull/3) ([benoror](https://github.com/benoror)) + +## [v0.1.2](https://github.com/kategengler/ember-cli-code-coverage/tree/v0.1.2) (2016-05-15) +[Full Changelog](https://github.com/kategengler/ember-cli-code-coverage/compare/v0.1.1...v0.1.2) + +**Closed issues:** + +- Take over the 'ember-cli-istanbul' package? [\#6](https://github.com/kategengler/ember-cli-code-coverage/issues/6) +- Testem global not found [\#1](https://github.com/kategengler/ember-cli-code-coverage/issues/1) + +**Merged pull requests:** + +- Allow users config to override the default config. [\#5](https://github.com/kategengler/ember-cli-code-coverage/pull/5) ([rwjblue](https://github.com/rwjblue)) + +## [v0.1.1](https://github.com/kategengler/ember-cli-code-coverage/tree/v0.1.1) (2016-05-05) +[Full Changelog](https://github.com/kategengler/ember-cli-code-coverage/compare/v0.1.0...v0.1.1) + +## [v0.1.0](https://github.com/kategengler/ember-cli-code-coverage/tree/v0.1.0) (2016-05-03) +[Full Changelog](https://github.com/kategengler/ember-cli-code-coverage/compare/v0.0.1...v0.1.0) + +## [v0.0.1](https://github.com/kategengler/ember-cli-code-coverage/tree/v0.0.1) (2016-05-03) + + +\* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)* \ No newline at end of file From 79819772c90354e19510de56c21d63350db9d504 Mon Sep 17 00:00:00 2001 From: Arjan Singh Date: Wed, 14 Sep 2016 14:22:33 -0700 Subject: [PATCH 17/39] Remove stray console.log --- index.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/index.js b/index.js index d14ffa6d..2a40700d 100644 --- a/index.js +++ b/index.js @@ -206,8 +206,6 @@ module.exports = { this._doesFileExistIsCurrentProjectAddonModule(relativePath) ); - console.log(!fileExists, name, relativePath); - return !fileExists; }, From e6ed56bf89c21b890b7fe07efb4696e0562c5af1 Mon Sep 17 00:00:00 2001 From: Katie Gengler Date: Thu, 15 Sep 2016 08:15:40 -0400 Subject: [PATCH 18/39] Some clarifications in Readme --- README.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 224e05b4..05bc9810 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,7 @@ Code coverage using [Istanbul](https://github.com/gotwarlost/istanbul) for Ember * If using Mocha, Testem `>= 1.6.0` for which you need ember-cli `> 2.4.3` * If using Mirage you need `ember-cli-mirage >= 0.1.13` * If using Pretender (even as a dependency of Mirage) you need `pretender >= 0.11.0` +* If using Mirage or Pretender, you need to [set up a passthrough for coverage to be written](#create-a-passthrough). ## Installation @@ -14,7 +15,7 @@ Code coverage using [Istanbul](https://github.com/gotwarlost/istanbul) for Ember ## Usage -Coverage will only be generated when an environment variable is true (by default `COVERAGE`) and running your test command like normal. +Coverage will only be generated when an [environment variable](https://en.wikipedia.org/wiki/Environment_variable) is true (by default `COVERAGE`) and running your test command like normal. For example: @@ -43,9 +44,9 @@ Configuration is optional. It should be put in a file at `config/coverage.js`. } ``` -## Using when intercepting all ajax requests in tests +## [Create as passthrough when intercepting all ajax requests in tests](#create-a-passthrough) -Aka when using ember-cli-mirage or Pretender. You may require a version of Pretender that includes [this fix](https://github.com/pretenderjs/pretender/pull/130). +(When using ember-cli-mirage or Pretender.) To work, this addon has to post coverage results back to a middleware at `/write-coverage`. From d7f01303012f4168dd69a1f728cbfdee7ca6d3e9 Mon Sep 17 00:00:00 2001 From: Katie Gengler Date: Thu, 15 Sep 2016 08:17:36 -0400 Subject: [PATCH 19/39] Update README.md --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 05bc9810..0d95a8b0 100644 --- a/README.md +++ b/README.md @@ -44,7 +44,9 @@ Configuration is optional. It should be put in a file at `config/coverage.js`. } ``` -## [Create as passthrough when intercepting all ajax requests in tests](#create-a-passthrough) +## Create as passthrough when intercepting all ajax requests in tests + +[passthrough-info](#create-a-passthrough) (When using ember-cli-mirage or Pretender.) From ade117d71294ff5caaed7f87443343bdf2ef62d2 Mon Sep 17 00:00:00 2001 From: Katie Gengler Date: Thu, 15 Sep 2016 08:20:18 -0400 Subject: [PATCH 20/39] Update README.md Last try on this anchor business --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 0d95a8b0..5af9e569 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Code coverage using [Istanbul](https://github.com/gotwarlost/istanbul) for Ember * If using Mocha, Testem `>= 1.6.0` for which you need ember-cli `> 2.4.3` * If using Mirage you need `ember-cli-mirage >= 0.1.13` * If using Pretender (even as a dependency of Mirage) you need `pretender >= 0.11.0` -* If using Mirage or Pretender, you need to [set up a passthrough for coverage to be written](#create-a-passthrough). +* If using Mirage or Pretender, you need to [set up a passthrough for coverage to be written](#passthrough). ## Installation @@ -44,9 +44,9 @@ Configuration is optional. It should be put in a file at `config/coverage.js`. } ``` -## Create as passthrough when intercepting all ajax requests in tests +## When intercepting all ajax requests in tests -[passthrough-info](#create-a-passthrough) +### passthrough (When using ember-cli-mirage or Pretender.) From a4368a785b3e487bf30a7fd9b2f8c8033bd56e25 Mon Sep 17 00:00:00 2001 From: Katie Gengler Date: Thu, 15 Sep 2016 08:21:18 -0400 Subject: [PATCH 21/39] Update README.md --- README.md | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 5af9e569..76b8fbdc 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Code coverage using [Istanbul](https://github.com/gotwarlost/istanbul) for Ember * If using Mocha, Testem `>= 1.6.0` for which you need ember-cli `> 2.4.3` * If using Mirage you need `ember-cli-mirage >= 0.1.13` * If using Pretender (even as a dependency of Mirage) you need `pretender >= 0.11.0` -* If using Mirage or Pretender, you need to [set up a passthrough for coverage to be written](#passthrough). +* If using Mirage or Pretender, you need to [set up a passthrough for coverage to be written](#create-a-passthrough-when-intercepting-all-ajax-requests-in-tests). ## Installation @@ -44,9 +44,7 @@ Configuration is optional. It should be put in a file at `config/coverage.js`. } ``` -## When intercepting all ajax requests in tests - -### passthrough +## Create a passthrough when intercepting all ajax requests in tests (When using ember-cli-mirage or Pretender.) From 89f688378daf097841df780d38b380fcd3529566 Mon Sep 17 00:00:00 2001 From: Robert Jackson Date: Thu, 15 Sep 2016 09:27:50 -0400 Subject: [PATCH 22/39] Update CHANGELOG for 0.3.1. --- CHANGELOG.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 174b0300..27462a16 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,16 @@ # Change Log +## [v0.3.1](https://github.com/kategengler/ember-cli-code-coverage/tree/v0.3.1) (2016-09-15) +[Full Changelog](https://github.com/kategengler/ember-cli-code-coverage/compare/v0.3.0...v0.3.1) + +**Closed issues:** + +- Add code coverage [\#34](https://github.com/kategengler/ember-cli-code-coverage/issues/34) + +**Merged pull requests:** + +- Remove stray console.log [\#35](https://github.com/kategengler/ember-cli-code-coverage/pull/35) ([arjansingh](https://github.com/arjansingh)) + ## [v0.3.0](https://github.com/kategengler/ember-cli-code-coverage/tree/v0.3.0) (2016-09-14) [Full Changelog](https://github.com/kategengler/ember-cli-code-coverage/compare/v0.2.2...v0.3.0) From a65761b337c32182eb673ae7abc842c0d7b9cd8d Mon Sep 17 00:00:00 2001 From: Robert Jackson Date: Thu, 15 Sep 2016 09:28:03 -0400 Subject: [PATCH 23/39] 0.3.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 70cc5165..f69aff91 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ember-cli-code-coverage", - "version": "0.3.0", + "version": "0.3.1", "description": "Code coverage for ember projects using Istanbul", "directories": { "doc": "doc", From 880ba916f14b0c85541abbe2bd90502b19afc492 Mon Sep 17 00:00:00 2001 From: Kelly Selden Date: Thu, 15 Sep 2016 09:46:33 -0700 Subject: [PATCH 24/39] add Windows notes --- README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/README.md b/README.md index 76b8fbdc..9713ac8a 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,14 @@ For example: `COVERAGE=true ember test` +If you want your coverage to work on both Unix and Windows, you can do this: + +`npm install cross-env --save-dev` + +and then: + +`cross-env COVERAGE=true ember test` + ## Configuration Configuration is optional. It should be put in a file at `config/coverage.js`. From 49cdf9398f08b57d91caec2bbe9ab37534ace2e3 Mon Sep 17 00:00:00 2001 From: Dan Freeman Date: Mon, 19 Sep 2016 16:11:57 -0400 Subject: [PATCH 25/39] Fix hang when running in PhantomJS. --- lib/templates/test-body-footer.html | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/templates/test-body-footer.html b/lib/templates/test-body-footer.html index 573a1ac6..ad75072f 100644 --- a/lib/templates/test-body-footer.html +++ b/lib/templates/test-body-footer.html @@ -12,6 +12,11 @@ request.onload = function() { var data = this.response; + // PhantomJS doesn't honor `responseType = 'json'` + if (typeof data === 'string') { + data = JSON.parse(data); + } + if (!data || !data.total) { return; } From 05ab44e72a54ebcaa614e4cbd6284afe8e5c8774 Mon Sep 17 00:00:00 2001 From: Robert Jackson Date: Mon, 19 Sep 2016 14:15:30 -0700 Subject: [PATCH 26/39] Update CHANGELOG for v0.3.2. --- CHANGELOG.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 27462a16..605dbc77 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,18 @@ # Change Log +## [v0.3.2](https://github.com/kategengler/ember-cli-code-coverage/tree/v0.3.2) (2016-09-19) +[Full Changelog](https://github.com/kategengler/ember-cli-code-coverage/compare/v0.3.1...v0.3.2) + +**Closed issues:** + +- Integration components support [\#40](https://github.com/kategengler/ember-cli-code-coverage/issues/40) +- Addon tests never exit [\#37](https://github.com/kategengler/ember-cli-code-coverage/issues/37) + +**Merged pull requests:** + +- Fix hang when running in PhantomJS. [\#43](https://github.com/kategengler/ember-cli-code-coverage/pull/43) ([dfreeman](https://github.com/dfreeman)) +- add Windows notes [\#38](https://github.com/kategengler/ember-cli-code-coverage/pull/38) ([kellyselden](https://github.com/kellyselden)) + ## [v0.3.1](https://github.com/kategengler/ember-cli-code-coverage/tree/v0.3.1) (2016-09-15) [Full Changelog](https://github.com/kategengler/ember-cli-code-coverage/compare/v0.3.0...v0.3.1) From 0b6ebaaf245739c255edbd5e2a557008ba11a683 Mon Sep 17 00:00:00 2001 From: Robert Jackson Date: Mon, 19 Sep 2016 14:16:09 -0700 Subject: [PATCH 27/39] 0.3.2 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index f69aff91..123e7314 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ember-cli-code-coverage", - "version": "0.3.1", + "version": "0.3.2", "description": "Code coverage for ember projects using Istanbul", "directories": { "doc": "doc", From 63c3b46be1419ceb0966c491543e10f7376163a2 Mon Sep 17 00:00:00 2001 From: Dan Freeman Date: Wed, 21 Sep 2016 14:29:38 -0400 Subject: [PATCH 28/39] Handle addons with different package names. --- index.js | 32 ++++++++++++++++++--- test/unit/index-test.js | 63 +++++++++++++++++++++++++++++++++++++++-- 2 files changed, 88 insertions(+), 7 deletions(-) diff --git a/index.js b/index.js index 2a40700d..82f71b60 100644 --- a/index.js +++ b/index.js @@ -17,7 +17,7 @@ module.exports = { included: function() { if (this._isCoverageEnabled() && this.parent.isEmberCLIAddon()) { - var coveredAddon = this.project.findAddonByName(this.project.pkg.name); + var coveredAddon = this._findCoveredAddon(); var coverageAddonContext = this; coveredAddon.processedAddonJsFiles = function (tree){ @@ -65,7 +65,7 @@ module.exports = { // Instrument JavaScript for code coverage var instrumentedNode = new CoverageInstrumenter(appFiles, { annotation: 'Instrumenting for code coverage', - appName: this.parent.pkg.name, + appName: this._parentName(), appRoot: this.parent.root, babelOptions: this.app.options.babel, useBabelInstrumenter: useBabelInstrumenter, @@ -130,7 +130,7 @@ module.exports = { * @returns {Boolean} whether or not the file exists within the current app */ _doesFileExistIsCurrentProjectAddonModule: function(relativePath) { - relativePath = path.join('addon', relativePath.replace(path.join('modules', this.project.pkg.name),'')); + relativePath = path.join('addon', relativePath.replace(path.join('modules', this._parentName()),'')); if (this._existsSync(relativePath)) { return true; @@ -223,7 +223,7 @@ module.exports = { */ _getExcludes: function() { var excludes = this._getConfig().excludes || []; - var name = this.parent.pkg.name; + var name = this._parentName(); excludes.push(this._filterOutAddonFiles.bind(this, name)); return excludes; @@ -241,5 +241,29 @@ module.exports = { } return ['true', true].indexOf(value) !== -1; + }, + + /** + * Determine the name of the parent app or addon. + * @returns {String} the name of the parent + */ + _parentName: function() { + if (this.parent.isEmberCLIAddon()) { + return this._findCoveredAddon().name; + } else { + return this.parent.name; + } + }, + + /** + * Find the addon (if any) that's being covered. + * @returns {Addon} the addon under test + */ + _findCoveredAddon: function() { + if (!this._coveredAddon) { + this._coveredAddon = this.project.findAddonByName(this.project.pkg.name); + } + + return this._coveredAddon; } }; diff --git a/test/unit/index-test.js b/test/unit/index-test.js index e81319fa..85f946d6 100644 --- a/test/unit/index-test.js +++ b/test/unit/index-test.js @@ -249,13 +249,13 @@ describe('index.js', function() { }); }); - describe('_getEcludes', function() { + describe('_getExcludes', function() { beforeEach(function() { sandbox.stub(Index, '_filterOutAddonFiles').returns('test'); Index.parent = { - pkg: { - name: 'foo-bar' + isEmberCLIAddon: function() { + return false; } }; }); @@ -397,4 +397,61 @@ describe('index.js', function() { }); }); }); + + describe('_parentName', function() { + var isAddon; + + beforeEach(function() { + Index.parent = { + name: 'parent-app', + isEmberCLIAddon: function() { + return isAddon; + } + }; + }); + + describe('when parent is an app', function() { + beforeEach(function() { + isAddon = false; + }); + + it('returns the app name', function() { + expect(Index._parentName()).to.equal('parent-app'); + }); + }); + + describe('when parent is an addon', function() { + beforeEach(function() { + isAddon = true; + sandbox.stub(Index, '_findCoveredAddon').returns({ name: 'some-addon' }); + }); + + it('returns the addon name', function() { + expect(Index._parentName()).to.equal('some-addon'); + }); + }); + }); + + describe('_findCoveredAddon', function() { + var result; + + beforeEach(function() { + Index.project = { + findAddonByName: sinon.stub().returns({ name: 'my-addon' }), + pkg: { + name: '@scope/ember-cli-my-addon' + } + }; + + result = Index._findCoveredAddon(); + }); + + it('looks up the addon by the package name', function() { + expect(Index.project.findAddonByName.calledWith('@scope/ember-cli-my-addon')).to.be.true; + }); + + it('returns the located addon', function() { + expect(result.name).to.equal('my-addon'); + }); + }); }); From e66c4dfd9f0d1f4da6839b83992a5fe10a1f7dbe Mon Sep 17 00:00:00 2001 From: Robert Jackson Date: Fri, 7 Oct 2016 11:28:37 -0400 Subject: [PATCH 29/39] Use posix paths for dealing with modules. Let the underlying subsystem deal with the `path.sep` differences, the logic here was incorrectly interchanging `\` and `/` on windows. --- index.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 82f71b60..b960a316 100644 --- a/index.js +++ b/index.js @@ -129,8 +129,9 @@ module.exports = { * @param {String} relativePath - path to file within current app * @returns {Boolean} whether or not the file exists within the current app */ - _doesFileExistIsCurrentProjectAddonModule: function(relativePath) { - relativePath = path.join('addon', relativePath.replace(path.join('modules', this._parentName()),'')); + _doesFileExistIsCurrentProjectAddonModule: function(_relativePath) { + var relativePathWithoutProjectNamePrefix = _relativePath.replace('modules' + '/' + this._parentName(), ''); + var relativePath = 'addon/' + relativePathWithoutProjectNamePrefix; if (this._existsSync(relativePath)) { return true; From 1afa6edc5865a16c93eec837099cf83120882879 Mon Sep 17 00:00:00 2001 From: Robert Jackson Date: Fri, 7 Oct 2016 11:48:53 -0400 Subject: [PATCH 30/39] 0.3.3 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 123e7314..d3a8cfc3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ember-cli-code-coverage", - "version": "0.3.2", + "version": "0.3.3", "description": "Code coverage for ember projects using Istanbul", "directories": { "doc": "doc", From 0cdcccecc2d1130c551c18ea6fa1f955c07637cb Mon Sep 17 00:00:00 2001 From: Robert Jackson Date: Fri, 7 Oct 2016 11:49:36 -0400 Subject: [PATCH 31/39] Update CHANGELOG for 0.3.3. --- CHANGELOG.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 605dbc77..cff7302a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,19 @@ # Change Log +## [v0.3.3](https://github.com/kategengler/ember-cli-code-coverage/tree/v0.3.3) (2016-10-07) +[Full Changelog](https://github.com/kategengler/ember-cli-code-coverage/compare/v0.3.2...v0.3.3) + +**Closed issues:** + +- Addon support: no coverage for addon files on Windows [\#48](https://github.com/kategengler/ember-cli-code-coverage/issues/48) +- No coverage when addon and package name don't match [\#45](https://github.com/kategengler/ember-cli-code-coverage/issues/45) +- Mocha phantom addon coverage issue in master causing a global error. [\#32](https://github.com/kategengler/ember-cli-code-coverage/issues/32) + +**Merged pull requests:** + +- Use posix paths for dealing with modules. [\#50](https://github.com/kategengler/ember-cli-code-coverage/pull/50) ([rwjblue](https://github.com/rwjblue)) +- Handle addons with different package names [\#46](https://github.com/kategengler/ember-cli-code-coverage/pull/46) ([dfreeman](https://github.com/dfreeman)) + ## [v0.3.2](https://github.com/kategengler/ember-cli-code-coverage/tree/v0.3.2) (2016-09-19) [Full Changelog](https://github.com/kategengler/ember-cli-code-coverage/compare/v0.3.1...v0.3.2) From ecdae6e4bd5d6c9818cf4279900897829f7a5eea Mon Sep 17 00:00:00 2001 From: nfc036 Date: Mon, 10 Oct 2016 13:31:13 +0200 Subject: [PATCH 32/39] return actual name not function from _parentName this.parent.name is a function (if defined), this.parent.pkg.name is the expected name of the package. --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index b960a316..8cad6680 100644 --- a/index.js +++ b/index.js @@ -252,7 +252,7 @@ module.exports = { if (this.parent.isEmberCLIAddon()) { return this._findCoveredAddon().name; } else { - return this.parent.name; + return this.parent.pkg.name; } }, From dae3da1ddea1057f12b0d7ee8306619617cb9b5b Mon Sep 17 00:00:00 2001 From: nfc036 Date: Mon, 10 Oct 2016 14:15:24 +0200 Subject: [PATCH 33/39] parent.name is function not string Tests adjusted according to [ember-cli/lib/models/project.js](https://github.com/ember-cli/ember-cli/blob/1cae632e9724d0fc02cb91e90d83e70e78f75069/lib/models/project.js#L142). --- test/unit/index-test.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/test/unit/index-test.js b/test/unit/index-test.js index 85f946d6..2b542be6 100644 --- a/test/unit/index-test.js +++ b/test/unit/index-test.js @@ -256,6 +256,9 @@ describe('index.js', function() { Index.parent = { isEmberCLIAddon: function() { return false; + }, + name: function() { + return 'test'; } }; }); @@ -403,7 +406,9 @@ describe('index.js', function() { beforeEach(function() { Index.parent = { - name: 'parent-app', + name: function() { + return 'parent-app'; + }, isEmberCLIAddon: function() { return isAddon; } From 6f86df5cde4ffd8d786247a80d9fd51e781fcb8d Mon Sep 17 00:00:00 2001 From: nfc036 Date: Mon, 10 Oct 2016 14:16:50 +0200 Subject: [PATCH 34/39] Update index.js --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index 8cad6680..72c2b63b 100644 --- a/index.js +++ b/index.js @@ -252,7 +252,7 @@ module.exports = { if (this.parent.isEmberCLIAddon()) { return this._findCoveredAddon().name; } else { - return this.parent.pkg.name; + return this.parent.name(); } }, From 5b33adb2488d27d7db315be29038ec1f5dd29be8 Mon Sep 17 00:00:00 2001 From: Robert Jackson Date: Mon, 10 Oct 2016 10:01:57 -0400 Subject: [PATCH 35/39] Update CHANGELOG.md for 0.3.4. --- CHANGELOG.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index cff7302a..144a8bac 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,16 @@ # Change Log +## [v0.3.4](https://github.com/kategengler/ember-cli-code-coverage/tree/v0.3.4) (2016-10-10) +[Full Changelog](https://github.com/kategengler/ember-cli-code-coverage/compare/v0.3.3...v0.3.4) + +**Closed issues:** + +- Missing coverage information in top-level addons in 0.3.3. [\#53](https://github.com/kategengler/ember-cli-code-coverage/issues/53) + +**Merged pull requests:** + +- return actual name not function from \_parentName [\#52](https://github.com/kategengler/ember-cli-code-coverage/pull/52) ([nfc036](https://github.com/nfc036)) + ## [v0.3.3](https://github.com/kategengler/ember-cli-code-coverage/tree/v0.3.3) (2016-10-07) [Full Changelog](https://github.com/kategengler/ember-cli-code-coverage/compare/v0.3.2...v0.3.3) From 473e2d6ff88ecede0f05f91344af7acd82a6689e Mon Sep 17 00:00:00 2001 From: Robert Jackson Date: Mon, 10 Oct 2016 10:02:11 -0400 Subject: [PATCH 36/39] 0.3.4 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index d3a8cfc3..0313e386 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ember-cli-code-coverage", - "version": "0.3.3", + "version": "0.3.4", "description": "Code coverage for ember projects using Istanbul", "directories": { "doc": "doc", From 0fdc0b142397c037324703218f8acc0f1155ae13 Mon Sep 17 00:00:00 2001 From: nfc036 Date: Mon, 10 Oct 2016 16:29:34 +0200 Subject: [PATCH 37/39] Cosmetics for docs, renamed function name and parameter name Renamed `_doesFileExistIsCurrentProjectAddonModule` to `_doesFileExistInCurrentProjectAddonModule` and its parameter from `_relativePath` to `relativePath` to make is consistent with other `_doesFileExist...`-functions. Cosmetics only, no functional changes. --- index.js | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/index.js b/index.js index 72c2b63b..ff55c070 100644 --- a/index.js +++ b/index.js @@ -124,21 +124,23 @@ module.exports = { return this._doesTemplateFileExist(relativePath); }, - /** + + /** * Check if a file exists within the current addon directory. Removing `module/` from the path. * @param {String} relativePath - path to file within current app * @returns {Boolean} whether or not the file exists within the current app */ - _doesFileExistIsCurrentProjectAddonModule: function(_relativePath) { - var relativePathWithoutProjectNamePrefix = _relativePath.replace('modules' + '/' + this._parentName(), ''); - var relativePath = 'addon/' + relativePathWithoutProjectNamePrefix; + _doesFileExistInCurrentProjectAddonModule: function(relativePath) { + var relativePathWithoutProjectNamePrefix = relativePath.replace('modules' + '/' + this._parentName(), ''); + var _relativePath = 'addon/' + relativePathWithoutProjectNamePrefix; - if (this._existsSync(relativePath)) { + if (this._existsSync(_relativePath)) { return true; } - return this._doesTemplateFileExist(relativePath); + return this._doesTemplateFileExist(_relativePath); }, + /** * Check if a file exists within the dummy app * @param {String} relativePath - path to file within dummy app @@ -204,7 +206,7 @@ module.exports = { this._doesFileExistInDummyApp(relativePath) || this._doesFileExistInCurrentProjectApp(relativePath) || this._doesFileExistInCurrentProjectAddon(relativePath) || - this._doesFileExistIsCurrentProjectAddonModule(relativePath) + this._doesFileExistInCurrentProjectAddonModule(relativePath) ); return !fileExists; From 4a878683f7e26108a49e892621cd047be5456ccc Mon Sep 17 00:00:00 2001 From: nfc036 Date: Mon, 10 Oct 2016 16:42:31 +0200 Subject: [PATCH 38/39] removed trailing spaces (eslint) spaces removed that lead to a failing eslint test. --- index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index ff55c070..17992ac4 100644 --- a/index.js +++ b/index.js @@ -124,7 +124,7 @@ module.exports = { return this._doesTemplateFileExist(relativePath); }, - + /** * Check if a file exists within the current addon directory. Removing `module/` from the path. * @param {String} relativePath - path to file within current app @@ -140,7 +140,7 @@ module.exports = { return this._doesTemplateFileExist(_relativePath); }, - + /** * Check if a file exists within the dummy app * @param {String} relativePath - path to file within dummy app From 43440508f26d7ac875a1d810c17c0773b9a8de6c Mon Sep 17 00:00:00 2001 From: EWhite613 Date: Fri, 14 Oct 2016 14:21:09 -0400 Subject: [PATCH 39/39] Fixes based on comments --- index.js | 7 ++++++- lib/attach-middleware.js | 7 +++---- lib/templates/test-body-footer.html | 2 -- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/index.js b/index.js index 864ae4c3..b9678767 100644 --- a/index.js +++ b/index.js @@ -90,7 +90,12 @@ module.exports = { */ testemMiddleware: function(app) { if (!this._isCoverageEnabled()) { return; } - attachMiddleware(app, { root: this.project.root, ui: this.ui, appName: this.parent.pkg.name, excludes: this._getConfig().excludes || [] }); + attachMiddleware(app, + { + root: this.project.root, + ui: this.ui, + appName: this.parent.pkg.name, + excludes: this._getConfig().excludes || [] }); }, // Custom Methods diff --git a/lib/attach-middleware.js b/lib/attach-middleware.js index 25140cc6..6ecd109e 100644 --- a/lib/attach-middleware.js +++ b/lib/attach-middleware.js @@ -44,15 +44,14 @@ module.exports = function(app, options) { return false } app.post('/filter-entries',bodyParser.urlencoded({ - limit: '50mb', + limit: options.root.coveragePostLimit ||'50mb', extended: false, - parameterLimit: 10000 + parameterLimit: options.root.coveragePostParameterLimit ||10000 }),bodyParser.json({ - limit: '50mb' + limit: options.root.coveragePostLimit || '50mb' }), function(req, res) { var entries = req.body['entries[]'] || req.body.entries - debugger var seen = {} var appName = options.appName var filteredEntries = entries.filter(function(entry) { diff --git a/lib/templates/test-body-footer.html b/lib/templates/test-body-footer.html index 8eb6ee4f..081fdc2f 100644 --- a/lib/templates/test-body-footer.html +++ b/lib/templates/test-body-footer.html @@ -59,9 +59,7 @@ } if (typeof Testem !== "undefined" && Testem.afterTests) { Testem.afterTests(function(config, data, callback) { - console.log('filtering entries') var entries = filterEntries(Object.keys(requirejs.entries)).entries - console.log(entries) for (var entry in entries){ console.warn('requiring unseen module: ' + entries[entry]) try {